frameworkModule.controller("AppSideBarController", ["$scope", "$log", "$timeout", "$rootScope", "appNavItemProvider", "appNav", "officeSvc", "localSvc", "$stateParams", "hebePortal", function(n, t, i, r, u, f, e, o, s) {
    "use strict";
    var c = function(n) {
            n.id === "new" && n.param.route === "enterpriseCenter.services" && Ares.sensors.track("ClinicCenter", { OperationType: "开发平台入口" });
            n.isActive && (n.id !== "new" || s.route === n.param.route) || f.goToState(n.id, n.param)
        },
        h = function() { e.getOfficePoint().then(function(t) { n.officePoint = t.data }) };
    (function() {
        n.navItems = u.navItems;
        n.navigate = c;
        h();
        r.$on("officePointChange", function(n, t) { t && h() })
    })()
}]);
frameworkModule.controller("AresAppCtrl", ["$log", "$modal", "$scope", "$state", "$window", "$rootScope", "$timeout", "loginContext", "appNav", "enums", "dataDicSvc", "appNavItemProvider", "permissionProvider", "localCache", "patientSvc", "eventAggregator", "userOptionSvc", "aresDialog", "tenantReportSvc", "officeSvc", "messengerSvc", "conversationSvc", "patientTabManager", "systemConfigSvc", "officeOptionSvc", "tenantSvc", "moduleOptionProvider", "userSvc", "functionGuideProvider", "$injector", "hebeBusinessPortal", "systemOptionSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt, it, rt, ut, ft, et, ot, st, ht, ct) {
    var bt = !1,
        kt = !1,
        dt = 0,
        ri = 20,
        yt = null,
        vt = function() { Ares.logOff() },
        ui = function() { s.goToTenantSetting() },
        gt = function() { return yt || (yt = window.Ares3 ? st.get("ares3NavItemProvider") : st.get("appNavItemProvider")), yt },
        lt = { isScheduleCenterVisible: !1, isPatientCenterVisible: !1, isPatientHostVisible: !1, isDefaultVisible: !0 },
        at = null;
    lt.calculateDefaultState = function() { lt.isDefaultVisible = !lt.isScheduleCenterVisible && !lt.isPatientCenterVisible && !lt.isPatientHostVisible };
    f.$on("$stateChangeSuccess", function() {
        var n = r.includes("scheduleCenter") || r.includes("groupScheduleCenter");
        lt.isScheduleCenterVisible != n && (lt.isScheduleCenterVisible = n, p.publish(p.events.ScheduleCenterVisibleChanged, lt.isScheduleCenterVisible))
    });
    var fi = function() {
            f.$on("$stateChangeSuccess", function(n, t, i, u, f) {
                var e = r.includes("scheduleCenter") || r.includes("groupScheduleCenter");
                lt.isScheduleCenterVisible != e && (lt.isScheduleCenterVisible = e, p.publish(p.events.ScheduleCenterVisibleChanged, lt.isScheduleCenterVisible));
                at = {};
                at.event = n;
                at.toState = t;
                at.toParams = i;
                at.fromState = u;
                at.fromParams = f
            })
        },
        ei = function() {
            f.$on("$stateChangeStart", function(n, t, i, r, u) { r._hasConfirmed || (n.preventDefault(), s.confirmLeave(n, t, i, r, u).then(function() { s.confirmEnter(n, t, i, r, u) })) });
            f.$on("$stateChangeSuccess", function(n, t, i, r) {
                r._hasConfirmed = !1;
                pt()
            })
        },
        pt = function() {
            var o, l, h, u, c;
            i.permissionsLoaded && at || setTimeout(pt, 100);
            var v = at.event,
                t = at.toState,
                y = at.toParams,
                w = at.fromState,
                b = at.fromParams;
            if (at = null, lt.isPatientCenterVisible = r.includes("patientCenter"), o = !r.includes("patientCenter") && t.name.indexOf("patient") == 0, o && (l = a.isPatientCenterAllowed(), o &= l), lt.isPatientHostVisible != o && (lt.isPatientHostVisible = o, p.publish(p.events.PatientHostVisibleChanged, lt.isPatientHostVisible)), lt.calculateDefaultState(), h = t.name == "noPermssion", h || (u = gt(), c = u.initNavItemState() || t.name === "new", lt.isPatientHostVisible ? (u.patientHost.isActive = !0, u.patientHost.isSingleMode = t.url.indexOf("/signle/") > -1, u.patientHost.isSingleMode && (u.patientHost.patientId = r.params.patientId)) : u.patientHost.isActive = !1, c |= u.patientHost.isActive, h = c, u.patientHost.isActive && (h = t.permissionCode === null || a.isAllowed(t.permissionCode))), !h && t.name != "openPlatformCenter" && t.name != "pttCenter") {
                n.error("无权限访问" + t.name);
                e(function() { s.goToState("noPermssion") }, 100);
                return
            }
            f.currentState = t.name;
            t.onActivated && t.onActivated();
            s.onStateChanged(v, t, y, w, b);
            lt.isPatientHostVisible && (tt.isEmpty() && !a.isAllowed("patientCenter.allPatients") || e(function() {
                var n = $("#patientHostContainer").find(".k-splitter");
                n && kendo.resize(n)
            }, 5));
            Ares.sensors.autotrackspa()
        },
        ni = function() { var n = t.open({ animation: !0, backdrop: "static", template: "<office-switch-view><\/office-switch-view>", controller: "OfficeSwitchCtrl", size: "sm" }) },
        wt = function(n) { var i = t.open({ animation: !0, backdrop: "static", keyboard: !1, template: "<user-password-edit-view><\/user-password-edit-view>", controller: "UserPasswordEditCtrl", windowClass: "small-dialog", size: "sm", resolve: { host: function() { return { id: o.userId, account: o.userAccount, isHideCloseBtn: n } } } }) },
        oi = function() {
            p.subscribe(i, p.events.OfficeChanged, ti);
            p.subscribe(i, p.events.ApiErrorHappened, si);
            p.subscribe(i, p.events.UserKicked, hi)
        },
        ti = function(n, t) { t.id == o.officeId && (i.currentOffice = _.clone(t), i.officeName = t.abbreviation || t.name) },
        si = function(n, t) {
            (t.data.name == "AppointmentOperationException" || t.data.name == "AresBusinessException" || t.data.name == "CssdException" || t.data.autoAlert) && b.info("系统提示", t.data.message)
        },
        hi = function() {
            bt || b.warn("警告", "当前帐号已经在另一个客户端登录，如需继续使用，您需要重新登录。").then(function() { vt() }, function() { vt() });
            bt = !0
        },
        ci = function() { s.goToState("AliTurnOn.open") },
        li = function() { f.isNewWxEnabled && f.scrmChat && (f.isShowWxWebChat = !f.isShowWxWebChat, kt || ii(), $(".scrm-webchat-view").css({ left: "50%", "margin-left": "-525px", top: 0 }), Ares.sensors.track("AppTopBarEvent", { EventType: "微信" })) },
        ii = function() {
            e(function() {
                try {
                    $(".scrm-webchat-view").draggable({ cancel: "#char_scrm,.scrm_close" });
                    kt = !0
                } catch (t) {
                    dt++;
                    dt > ri ? n.log(t) : ii()
                }
            }, 200)
        },
        ai = function() {
            window.addEventListener("message", function(n) {
                if (n && n.data && n.data.source === "etrade") switch (n.data.action) {
                    case "switchOffice":
                        i.canSwitchOffice && ni();
                        break;
                    case "changePassword":
                        wt();
                        break;
                    case "logout":
                        vt();
                        break;
                    case "customerService":
                        i.onWebchatClick()
                }
            })
        },
        vi = function() {
            c.officeDic || c.initialize();
            c.officeDic.load().then(function(n) {
                o.hasMultiOffices = n.length > 1;
                i.canSwitchOffice = n.length > 1 && !o.isAdminOffice && (o.isRoot || o.offices.length > 1);
                var t = _.find(n, function(n) { return n.id == o.officeId });
                t || o.officeId != d.adminOffice.id || (t = d.adminOffice);
                ti(null, t);
                ai();
                window.location.hash && window.location.hash.length != 0 && window.location.hash != "#/default" || (o.officeEdition == h.BusinessEdition.FreeSupplychain ? s.goToState("supplychainReport") : o.isAdminOffice ? s.goToDashboard() : (o.officeType === 1 ? o.isGroup && o.dashboardType ? s.goToDashboard() : s.goToState("default") : o.roleType == "公司管理员" ? o.officeEdition == h.BusinessEdition.Ultimate ? s.goToState("tenantReport") : s.goToState("operationReport") : o.roleType == "诊所管理员" ? s.goToState("operationReport") : o.dashboardType ? s.goToDashboard() : s.goToState("default"), i.dashboardType && s.goToDashboard()))
            })
        },
        yi = function() { ft.isUserSecurityEnabled() && et.needChangePassword().success(function(n) { n && wt(!0) }) },
        pi = function() {
            Ares.initLogOffUrl();
            g.initConnection(!0);
            k.getRemainedTrialDays().success(function(n) { n != null && (i.remainedTrialDays = n, i.isShowRemainedTrialDays = !0) });
            yi();
            ot.loadFunctionGuides()
        },
        wi = function() {
            var n = o.officeId,
                t = o.tenantId;
            return t + "-" + n
        },
        bi = function() { ut.GetTenantIsCustomizeOpen().then(function() { Ares.Loader.loadJs("//webchat.7moor.com/javascripts/7moorInit.js?accessId=61d45470-7d8f-11e7-9b99-9fef3987fec1&autoShow=false") }) },
        ki = function() { s.goToState("systemTool") },
        di = function() {
            o.providerJob === "医生" && rt.getOfficeOption(rt.optionKeys.IsHealthBureauDataExportEnabled_Shenzhen).then(function(n) {
                if (n) {
                    var i = t.open({ animation: !0, backdrop: "static", controller: "ShenzhenFaceRecognitionDialogCtrl", template: "<shenzhen-face-recognition-dialog><\/shenzhen-face-recognition-dialog>", windowClass: "shenzhen-health-face-recognition-window", keyboard: !1, resolve: { host: function() { return {} } } });
                    i.result.then(function(n) { n && Ares.logOff() })
                }
            })
        },
        gi = function() {
            ct.getSystemOption(ct.optionKeys.Ares2EndDate).then(function(n) {
                var i, e;
                if (n = moment(n, "YYYY-MM-DD"), n.isValid()) {
                    i = moment().startOf("d");
                    n = n.startOf("d");
                    var r = i.isBefore(n, "d"),
                        u = v.getCache(v.keys.Ares3TrialBannerShowNoMore),
                        f = u.loadValue();
                    r && f !== "1" && (e = t.open({ animation: !0, backdrop: "static", controller: "Ares3CountDownDialogCtrl", template: "<ares3-count-down-dialog-view><\/ares3-count-down-dialog-view>", keyboard: !1, windowClass: "ares3-count-down-dialog-wrapper", resolve: { host: function() { return {} } } }))
                }
            })
        },
        nr = function() {
            Ares.sensors.track("Ares2Ares3", { Ares2Ares3Action: "MenuToAres3" });
            w.setUserOption(w.userOptionKey.selectedVersion, "3.0").then(function() { window.location = "/ares3/" })
        },
        tr = function() {
            var n = function() {
                var n = v.getCache(v.keys.LastLoginTime),
                    t = parseInt(n.loadValue());
                t && moment(t).diff(moment(), "hour") <= -18 && (n.clear(), Ares.logOff())
            };
            n();
            setInterval(n, 36e5)
        };
    (function() {
        try {
            var n = st.get("ssoNav");
            n && n.init()
        } catch (t) {} f.isWxClinic = !1;
        i.isInitialized = !1;
        i.containerState = lt;
        i.$state = r;
        i.logOff = vt;
        i.goToTenantSetting = ui;
        i.turnOnAliPay = ci;
        i.openMainConversation = li;
        i.login = o;
        i.canSwitchOffice = !1;
        i.switchOffice = ni;
        i.changePwd = wt;
        i.systemTool = ki;
        i.hasTenantSettingPermission = !1;
        i.remainedTrialDays = "";
        i.isShowRemainedTrialDays = !1;
        i.$root.isRegularChain = o.isRegularChain;
        i.$root.officeId = o.officeId;
        i.$root.isTenantAdmin = o.isTenantAdmin;
        i.$root.containerState = lt;
        oi();
        fi();
        ht.init();
        a.loadPermissions().then(function() {
            tt.initialize();
            var n = gt();
            n.initialize().then(function() {
                initMakeTemplate();
                ei();
                c.initialize();
                w.load();
                i.hasTenantSettingPermission = a.isAllowed("tenantSettings");
                i.isInitialized = !0;
                i.$root.isInitialized = !0;
                p.publish("appInitialized");
                i.permissionsLoaded = !0;
                at && pt()
            })
        });
        e(function() { vi() }, 500);
        e(function() { pi() }, 1e3);
        window.onunload = function() { Ares.logOff(!0) };
        di();
        gi();
        tr();
        i.qimoClientId = wi();
        i.loadQimoJS = bi;
        i.switchNewVersion = nr;
        i.isAres3Enabled = ft.isAres3Enabled()
    })()
}]);
frameworkModule.controller("AresCustomizeReportCtrl", ["$log", "$modal", "$scope", "dataDicSvc", "appNavItemProvider", "permissionProvider", "eventAggregator", "userOptionSvc", "patientTabManager", function(n, t, i, r, u, f, e, o) {
    (function() {
        f.loadPermissions().then(function() {
            u.initialize();
            r.initialize();
            o.load();
            i.hasTenantSettingPermission = f.isAllowed("tenantSettings");
            i.isInitialized = !0;
            i.$root.isInitialized = !0;
            e.publish("appInitialized")
        })
    })()
}]);
frameworkModule.controller("AresReportAppCtrl", ["$log", "dataDicSvc", function(n, t) {
    (function() { t.initialize() })()
}]);
frameworkModule.controller("MessageDetailCtrl", ["$scope", "$log", "$modalInstance", "$interpolate", "userSvc", "host", function(n, t, i, r, u, f) {
    "use strict";
    var e = function() { i.close("close") },
        o = function() {
            var t = n.message;
            u.ignoreMessage(t.id).success(function() { i.close("ignore") })
        };
    (function() {
        n.message = f.message;
        n.content = f.message.content;
        n.close = e;
        n.ignoreMessage = o
    })()
}]);
frameworkModule.controller("MessageCtrl", ["$scope", "$log", "$modal", "$timeout", "$q", "userSvc", "systemMessageSvc", "messageCenterSvc", "appNav", "userOptionSvc", "permissionProvider", "sessionCache", "$filter", "loginContext", "practiceSvc", "officeOptionSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p) {
    "use strict";
    var b, vt = a("toLongDateTimeString"),
        w = { weChatBizMessageCode: "scheduleCenter.weixinApplyList", unChargeMessageCode: "dashBoard.uncharge", stockRemindMessageCode: "inventoryBrowse.stockStatus", shortMessageBackCode: "shortMessaage.reply", shortMessageRemindCode: "shortMessage.charge", workflowReminderCode: "workflowManagement.approval", memoMessageCode: "memoManagement.record", strongRemind: "scheduleCenter.strongRemind", editMedicalRecordCode: "patientMedicalRecord.create" },
        it = l.getCache(l.keys.MessageCenterIgnoredBizMessageCode),
        rt = function() {
            var t = it.loadObject();
            t && _.extend(n.bizMessageCodes, t)
        },
        k = function(n, t, i, r, u) { n.push(ut(t, i, r, u)) },
        ut = function(n, t, i, r) { return { menuName: n.title, menuClass: t, menuBigClass: i, state: r, createTimeText: n.createTimeText, createTimeFormatText: n.createTimeFormatText, count: n.count, isShow: !0, isShowDel: !1, content: n.content, messageItems: n.messageItems } },
        yt = function(n) {
            var t = [],
                r, i, u;
            return n && $.each(n, function(n, i) { i.messageType == "系统公告" ? k(t, i, "系统公告", "系统公告", "") : i.messageType == "网络预约" ? k(t, i, "网络预约", "业务提醒", "dashBoard.appointApply") : i.messageType == "收费提醒" ? k(t, i, "收费提醒", "业务提醒", "dashBoard.uncharge") : i.messageType == "库存预警" && c.isAllowed(w.stockRemindMessageCode) ? k(t, i, "库存预警", "预警信息", "supplychain.inventory.stockRemind") : i.messageType == "短信预警" ? k(t, i, "短信预警", "预警信息", "shortMessage.charge") : i.messageType == "短信回复" ? k(t, i, "短信回复", "业务提醒", "shortMessage.feedback") : i.messageType == "审批提醒" ? k(t, i, "审批提醒", "业务提醒", "workflowManagement.approval") : i.messageType == "备忘提醒" ? k(t, i, "备忘提醒", "业务提醒", "memo.list") : i.messageType == "病历打回" && k(t, i, "病历打回", "业务提醒", "medicalrecordCenter.myEmr") }), r = _.filter(t, { menuBigClass: "系统公告" }), r && r.length == 0 && t.push({ menuClass: "系统公告", menuBigClass: "系统公告", count: 0 }), i = _.filter(t, { menuBigClass: "业务提醒" }), i && i.length == 0 && t.push({ menuClass: "网络预约", menuBigClass: "业务提醒", count: 0 }), i = _.filter(t, { menuBigClass: "预警信息" }), i && i.length == 0 && t.push({ menuClass: "库存预警", menuBigClass: "预警信息", count: 0 }), u = _.filter(t, { menuBigClass: "备忘提醒" }), u && u.length == 0 && t.push({ menuClass: "备忘提醒", menuBigClass: "备忘提醒", count: 0 }), t
        },
        ft = function(n) { it.saveObject(n) },
        d = function(t, i, r, u) {
            var f = _.filter(i, { messageType: r }),
                o = _.filter(n.bizMessageCodes, { code: u }),
                e;
            f.length > 0 && (o.length > 0 && o[0].time < f[0].createTimeText || o.length == 0) && (t || (t = []), e = _.find(t, { menuClass: r }), e ? (e.createTimeText = f[0].createTimeText, e.createTimeFormatText = f[0].createTimeFormatText, e.count = f[0].count, e.content = f[0].content, e.messageItems = f[0].messageItems) : t.push(f[0]))
        },
        pt = function(t, i, r, u, f) {
            var o = _.filter(i, { messageType: r }),
                e;
            o.length > 0 && r == "审批提醒" ? (e = _.find(t, { menuName: r }), e ? (!n.notTrouble && f && (e.isShow = !0, e.isChangeShow = f), e.createTimeText = o[0].createTimeText, e.createTimeFormatText = o[0].createTimeFormatText, e.count = o[0].count, e.content = o[0].content, e.messageItems = o[0].messageItems) : t.push(ut(o[0], "审批提醒", "业务提醒", "workflowManagement.approval"))) : t = _.filter(t, function(n) { return n.menuName != r });
            n.messageData = t
        },
        nt = function(n) {
            rt();
            et(b, n, !1)
        },
        et = function(n, t, i, r) { o.getMessages(n).success(function(n) { i ? wt(n, t, r) : bt(n, t) }) },
        wt = function(t, i, r) {
            if (pt(n.messageData, t, "审批提醒", w.workflowReminderCode, r), !i) {
                var u = _.filter(n.messageData, { menuBigClass: "预警信息" });
                _.each(u, function(n) { n.isShow = !1 });
                n.$emit("to-parent-messages", n.messageData)
            }
            ct()
        },
        bt = function(t, i) {
            var r = _.filter(t, { messageType: "系统公告" });
            d(r, t, "网络预约", w.weChatBizMessageCode);
            d(r, t, "收费提醒", w.unChargeMessageCode);
            d(r, t, "库存预警", w.stockRemindMessageCode);
            d(r, t, "短信预警", w.shortMessageRemindCode);
            d(r, t, "短信回复", w.shortMessageBackCode);
            d(r, t, "审批提醒", w.workflowReminderCode);
            d(r, t, "备忘提醒", w.memoMessageCode);
            d(r, t, "病历打回", w.editMedicalRecordCode);
            ht(r, !0);
            i || n.$emit("to-parent-messages", n.messageData)
        },
        ot = function() {
            var t = u.defer();
            return p.getOfficeOptions([p.optionKeys.IsMessageNotDisturbDisalbed, p.optionKeys.IsMessageClearAllDisalbed, p.optionKeys.MessagePostponeConfig]).then(function(i) {
                _.isArray(i) ? (n.isMessageNotDisturbDisalbed = !!i[0], n.isMessageClearAllDisalbed = !!i[1], n.isApptApplyDisabled = i[2] ? !!i[2].IsApptApplyDisabled : !1) : (n.isMessageNotDisturbDisalbed = !1, n.isMessageClearAllDisalbed = !1, n.isApptApplyDisabled = !1);
                t.resolve()
            }), t.promise
        },
        kt = function() {
            b = [];
            (c.isAllowed(w.weChatBizMessageCode) || v.dashboardType) && b.push(w.weChatBizMessageCode);
            c.isAllowed(w.shortMessageBackCode) && b.push(w.shortMessageBackCode);
            c.isAllowed(w.shortMessageRemindCode) && b.push(w.shortMessageRemindCode);
            v.dashboardType == "FrontDesk" ? (b.push(w.unChargeMessageCode), c.isAllowed(w.stockRemindMessageCode) && b.push(w.stockRemindMessageCode)) : c.isAllowed(w.stockRemindMessageCode) && b.push(w.stockRemindMessageCode);
            c.isAllowed(w.memoMessageCode) && b.push(w.memoMessageCode);
            c.isAllowed(w.strongRemind) && b.push(w.strongRemind);
            c.isAllowed(w.editMedicalRecordCode) && b.push(w.editMedicalRecordCode);
            b.push(w.workflowReminderCode);
            n.$on("to-child-messages", function(t, i) {
                n.messages = i;
                ht(n.messages, !1)
            });
            n.$on("to-child-messages-count", function(t, i) { n.messageFilterReadCnt = i });
            h.checkMsgNotTroubleMode().then(function(t) { n.notTrouble = n.isMessageNotDisturbDisalbed ? !1 : t })
        },
        dt = function(n) {
            f.readMessage(n.id).success(function(t) {
                var r = i.open({ animation: !0, backdrop: "static", template: "<message-detail-view><\/message-detail-view>", controller: "MessageDetailCtrl", windowClass: "message-detail-dialog", size: "lg", resolve: { host: function() { return { message: t } } } });
                nt();
                r.result.then(function(t) { t == "ignore" ? removeMessage(n.id) : st(n) }, function() { st(n) })
            })
        },
        gt = function(t) {
            (!t || n.notTrouble) && (h.setUserOption(h.userOptionKey.userMessageNotTrouble, !n.notTrouble), n.notTrouble = !n.notTrouble, n.$emit("to-parent-notTrouble", n.notTrouble))
        },
        ni = function(n, t) { t || f.ignoreMessage(n.id).success(function() { nt() }) },
        st = function() {},
        ht = function(t, i) {
            n.messageData = t && i ? yt(t) : t;
            ct()
        },
        ct = function() {
            n.messageData && (n.messageCnt = 0, n.messageFilterReadCnt = 0, $.each(n.messageData, function(t, i) {
                if (n.messageCnt += i.count, i.menuClass == "系统公告") {
                    var r = _.filter(i.messageItems, { hasRead: !1 });
                    n.messageFilterReadCnt += r.length
                } else n.messageFilterReadCnt += i.count
            }))
        },
        ti = function(t) {
            if (t.menuBigClass == "系统公告") {
                t.isShow = t.count > 0;
                t.count = t.count - 1;
                var i = _.filter(t.messageItems, { hasRead: !1 });
                i && (n.readMessage(i[i.length - 1].id), loadMessages())
            } else switch (t.menuClass) {
                case "网络预约":
                case "收费提醒":
                    v.dashboardType == "FrontDesk" ? s.switchState(t.state, { status: t.state }) : window.Ares3 ? s.goToState("new", { route: "appointment.apply" }) : s.goToState("apptMgmt.weixinApplyList");
                    break;
                case "库存预警":
                    c.isAllowed(w.stockRemindMessageCode) && s.goToState("supplychain.inventory.manage.currently");
                    break;
                case "备忘提醒":
                case "短信预警":
                case "病历打回":
                    s.goToState(t.state);
                    break;
                case "短信回复":
                    o.updateBizMessageLog(1);
                    s.goToState(t.state);
                    break;
                case "审批提醒":
                    o.updateBizMessageLog(6).then(function() {
                        var t = [];
                        t.push(n.keys.workflowReminderCode);
                        n.loadPermissionMessage(t, !1, !0)
                    });
                    s.goToState(t.state)
            }
        },
        ii = function(t) {
            var i = _.filter(n.messageData, { menuBigClass: t }),
                r = 0;
            return i && i.length > 0 && $.each(i, function(n, t) { r += t.count }), r
        },
        lt = function(t) {
            t || o.ignoreMyCache().success(function() {
                nt();
                n.$emit("to-parent-messages", n.messageData)
            })
        },
        ri = function(n) { n || (lt(n), tt("业务提醒", n), tt("预警信息", n)) },
        tt = function(t, i) {
            if (!i) {
                var r = _.filter(n.messageData, { menuBigClass: t });
                r && r.length > 0 && $.each(r, function(n, t) { at(t, i) })
            }
        },
        g = function(t, i, r, u) {
            var f = _.filter(n.bizMessageCodes, { code: i, time: r });
            (!f || f && f.length == 0) && t.menuClass == u && (n.bizMessageCodes.push({ code: i, time: r }), ft(n.bizMessageCodes), nt())
        },
        at = function(n, t) {
            if (!t) {
                var i;
                i = n ? n.createTimeText : vt(new Date);
                g(n, w.weChatBizMessageCode, i, "网络预约");
                g(n, w.unChargeMessageCode, i, "收费提醒");
                g(n, w.stockRemindMessageCode, i, "库存预警");
                g(n, w.shortMessageRemindCode, i, "短信预警");
                g(n, w.shortMessageBackCode, i, "短信回复");
                g(n, w.workflowReminderCode, i, "审批提醒");
                g(n, w.memoMessageCode, i, "备忘提醒");
                g(n, w.editMedicalRecordCode, i, "病历打回")
            }
        };
    (function() {
        n.keys = w;
        n.messageData = null;
        n.messageCnt = 0;
        n.messageFilterReadCnt = 0;
        n.bizMessageCodes = [];
        n.readMessage = dt;
        n.loadMessage = nt;
        n.loadPermissionMessage = et;
        n.ignoreMessage = ni;
        n.changeBellStatus = gt;
        n.initBizMessageCodeCache = rt;
        n.saveBizMessageCodes = ft;
        n.goToNavigate = ti;
        n.ignoreAllSystemMessages = lt;
        n.ignoreAllMessages = ri;
        n.ignoreAllBizMessages = tt;
        n.ignoreBizMessage = at;
        n.getBizMessageCount = ii;
        n.initMessageConfig = ot;
        ot().then(function() {
            kt();
            r(nt, 5e3)
        })
    })()
}]);
frameworkModule.controller("OfficeSwitchCtrl", ["$log", "$scope", "$modalInstance", "$http", "$timeout", "loginContext", "busyRequestNotificationHub", "aresDialog", "patientTabManager", "sessionCache", "dataDicSvc", function(n, t, i, r, u, f, e, o, s, h, c) {
    "use strict";
    var l = h.getCache(h.keys.EtradePlatformSendCouponState),
        a = "6E95084BF198E4C9",
        v = sessionStorage.getItem(a),
        y = function(n, t) {
            var u = Ares.getClientId(),
                i;
            t = t || !1;
            i = { account: f.userAccount, officeId: n, platform: 1, kickOther: t, clientId: u, deviceCode: v };
            e.requestStarted();
            r.post(window.location.origin + "/SwitchOffice", i).success(function(t) {
                e.requestEnded();
                sessionStorage && (sessionStorage.clear(), sessionStorage.setItem(a, v));
                t.State == 0 ? (Ares.disableAutoLogOff(), s && s.tabs.length > 0 && s.removeAll(), w(), b(), Ares.logOn(t)) : (t.State == 39 && alert("目标诊所设备未授权！"), p(t, n))
            }).error(function(t) {
                e.requestEnded();
                var i = { State: responseType.UnKnown, data: t };
                p(i, n)
            })
        },
        w = function() { c.initialize() },
        b = function() {
            var n = l.loadObject();
            l.saveObject(!1)
        },
        p = function(t, i) {
            n.error(t);
            t.State == 14 && o.confirm("提示", "系统检测到您在目标诊所可能已经登录，继续将强制退出前次登录，您是否要继续？").then(function() { y(i, !0) })
        },
        k = function() { i.dismiss("cancel") };
    (function() {
        t.switchOffice = y;
        t.cancel = k
    })()
}]);
frameworkModule.controller("PatientHostCtrl", ["$scope", "$log", "patientTabManager", function(n, t, i) {
    "use strict";
    (function() {
        n.selectedTab = null;
        n.patientTabManager = i
    })()
}]);
frameworkModule.controller("PatientInfoCtrl", ["$log", "$scope", "$filter", "$q", "$location", "$http", "$state", "$modal", "appNav", "patientSvc", "appointmentSvc", "aresDialog", "loginContext", "dataDicSvc", "formatUtil", "patientUtil", "aresNotification", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w) {
    "use strict";
    var k = function() {
            var n = t.patient.patientId || t.patientId;
            p.createFollowUpApptByPatientId(n).then(function() {
                b(n).then(function() {
                    t.$apply();
                    w.success("预约成功")
                })
            })
        },
        d = function() {
            var n = t.patientId;
            g(n).then(function() { nt(n).then(function() { tt(n).then(function() { b(n).then(function() { it(n).then(function() {}) }) }) }) })
        },
        g = function(n) {
            var i = r.defer();
            return h.getPatientLiteInfo(n, !0).success(function(n) {
                t.patient = n;
                i.resolve(n)
            }), i.promise
        },
        nt = function() {
            var n = r.defer();
            return h.getPictureById(t.patient.pictureId, !0).success(function(r) {
                t.patient.imgSrc = r != null ? r.filePath : i("patientPhoto")(null, t.patient);
                n.resolve(r)
            }), n.promise
        },
        tt = function(n) {
            var i = r.defer();
            return h.getBodyCheck(n, !0).success(function(n) {
                var r, u;
                t.bodycheck = n;
                n != null && (n.medicine != null && (r = n.medicine.split(","), t.medicine = n.medicine, t.medicines = r ? r : []), n.disease != null && (u = n.disease.split(","), t.diseases = u ? u : []));
                i.resolve(n)
            }), i.promise
        },
        b = function(n) {
            var u = r.defer();
            return c.getPatientLiteAppts(n, !0).success(function(n) {
                var h = i("toLongDateTimeString")(new Date),
                    r;
                n = _.filter(n, function(n) { return n.isCancelled == !1 && n.isFailed == !1 && n.isPending == !1 });
                _.each(n, function(n) { n.startTime = i("toLongDateTimeString")(n.startTime) });
                var f = _.filter(n, function(n) { return n.startTime <= h && (n.isCheckedIn == !0 || n.isCheckedOut == !0 || n.isCompleted == !0 || n.isSeated == !0) }),
                    s = _.filter(n, function(n) { return n.startTime > h && !(n.isCheckedIn == !0 || n.isCheckedOut == !0 || n.isCompleted == !0 || n.isSeated == !0) }),
                    e = {},
                    o = {};
                if (f.length > 0) {
                    var f = _.sortBy(f, function(n) { return n.startTime }),
                        c = f.length - 1,
                        r = f[c];
                    r.title = "上次就诊";
                    e = r
                } else r = { title: "上次就诊" }, e = r;
                if (s.length > 0) {
                    var s = _.sortBy(s, function(n) { return n.startTime }),
                        c = 0,
                        r = s[c];
                    r.title = "下次预约";
                    o = r
                } else r = { title: "下次预约" }, o = r;
                y.formatAppt(o);
                y.formatAppt(e);
                t.nextAppt = o;
                t.lastAppt = e;
                u.resolve(!0)
            }), u.promise
        },
        it = function(n) {
            var i = r.defer();
            return h.getAllTxPlanByPatient(n, !0).success(function(n) {
                v.txplanItemDic.load().then(function(r) {
                    var u = [];
                    angular.forEach(n, function(n) {
                        angular.forEach(n.txplanItemList, function(n) {
                            var t = _.find(r, function(t) { return t.id === n.transactionCodeId });
                            n.transactionCodeName = t ? t.name : "";
                            n.status == 1 ? n.statusStr = "已预约" : n.status == 0 ? n.statusStr = "待预约" : n.status == 2 && (n.statusStr = "已完成");
                            u.push(n)
                        })
                    });
                    t.txPlanData = n;
                    i.resolve(n)
                })
            }), i.promise
        };
    (function() {
        t.lastAppt = {};
        t.nextAppt = {};
        t.createFollowUpAppt = k;
        t.getPatientInfo = d
    })()
}]);
frameworkModule.controller("PatientMainInfoCtrl", ["$scope", "$log", function() {
    "use strict";
    (function() {})()
}]);
var objWinObj = null;
frameworkModule.controller("PatientMenuBarController", ["$scope", "$log", "$modal", "patientNav", "patientTabManager", "eventAggregator", "aresNotification", function(n, t, i, r, u, f, e) {
    "use strict";
    var o = function(t) {
            // console.log(n);
            // console.log(r);
            console.log(t);
            if (t && t.id == "patientDentalLab") {
                // return false;
            }
            if (objWinObj && objWinObj != null) objWinObj.close();
            var objWinObjUrl = "";
            if (t.id == "testData") {
                var LogOnResult = JSON.parse(localStorage['LogOnResult']);
                var physicianId = LogOnResult.id;
                window.open("http://localhost:8082/SublimeText3Project/Medical-front-end/index.html?type=testData&physicianId="+physicianId+"&patientId="+t.patientTab.id, "_blank");
                return false;
            }
            switch (t.id) {
                case "PatientHealth":
                    objWinObjUrl = "PatientHealth";
                    break;
                case "CardiovascularStatus":
                    objWinObjUrl = "CardiovascularStatus";
                    break;
                case "StateOfTheKidney":
                    objWinObjUrl = "StateOfTheKidney";
                    break;
                case "DiabeticState":
                    objWinObjUrl = "DiabeticState";
                    break;
                case "EyesightCondition":
                    objWinObjUrl = "EyesightCondition";
                    break;
                case "FootCare":
                    objWinObjUrl = "FootCare";
                    break;
            }
            // if(objWinObjUrl){
            //     objWinObj = window.open("/yayi/autologous/"+objWinObjUrl+".html", "_blank", "width=" + ($(".menu-div").eq(0).outerWidth()) + ",height=" + (window.screen.availHeight - $(".menu-div").eq(0).outerHeight(true) - 160) + ",screenX=" + ($(".menu-div").eq(0).offset().left - 14) + ",screenY=" + ($(".menu-div").eq(0).offset().top + $(".menu-div").eq(0).height() + 100) + ",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
            // }
            // if (objWinObj && objWinObj != null) {
            //     // console.log(objWinObj);
            //     objWinObj.close();
            // }
            if (!_.isObject(t)) throw new TypeError("onMenuSelected: menu should be an object type!");
            t.disabled || (u.activeTab && r.navigateToPatient(u.activeTab.id, t.id).then(function() { angular.forEach(n.patientTabManager.activeTab.showUserMenus, function(n) { n.active = t.id == n.id }) }), document.activeElement.blur())
        },
        s = function() {
            Ares.sensors.track("PatientMenuBar", { OperationType: "菜单配置" });
            var t = i.open({ animation: !0, backdrop: "static", template: "<patient-menu-config-view><\/patient-menu-config-view>", controller: "PatientMenuConfigCtrl", windowClass: "schedulerulesetting-dialog", size: "lg" });
            t.result.then(function(t) { t && (u.refreshPatientMenu(t), n.init(), e.success("保存成功")) })
        };
    (function() {
        n.patientTabManager = u;
        // console.log(o);
        n.onMenuSelectedS = o;
        n.onMenuSelected = o;
        n.openPatientMenuConfigDialog = s
    })()
}]);
frameworkModule.controller("PatientMenuConfigCtrl", ["$scope", "$log", "$modalInstance", "patientTabManager", "appNav", "userOptionSvc", function(n, t, i, r, u, f) {
    "use strict";
    var e = function() { i.dismiss("close") },
        o = function() {
            n.patientMenus = angular.copy(r.activeTab.menus);
            n.patientMenus = _.sortBy(n.patientMenus, "index");
            angular.forEach(n.patientMenus, function(n, t) { n.showIndex = t });
            n.patientTabManager = r
        },
        s = function(t) {
            n.selectMenu = t;
            angular.forEach(n.patientMenus, function(n) { n.selected = t.name == n.name })
        },
        h = function(t) {
            var i;
            if (n.selectMenu && (i = n.selectMenu.showIndex + t, i >= 0 || i < n.patientMenus.length)) {
                var r = _.clone(n.selectMenu),
                    u = _.clone(n.patientMenus[i]),
                    f = u.index;
                n.patientMenus[n.selectMenu.showIndex] = u;
                n.patientMenus[n.selectMenu.showIndex].index = r.index;
                n.patientMenus[n.selectMenu.showIndex].showIndex = r.showIndex;
                n.patientMenus[i] = r;
                n.patientMenus[i].index = f;
                n.patientMenus[i].showIndex = i;
                n.selectMenu = n.patientMenus[i]
            }
        },
        c = function() {
            var t = [];
            angular.forEach(n.patientMenus, function(n) { t.push({ name: n.name, isVisable: n.isVisable, index: n.index }) });
            f.setUserOption(f.userOptionKey.userPatientMenus, t).then(function() {
                angular.forEach(r.patientMenuDic, function(n) {
                    var i = _.find(t, function(t) { return t.name == n.name });
                    i && (n.isVisable = i.isVisable, n.index = i.index)
                });
                i.close(n.patientMenus)
            })
        };
    (function() {
        n.save = c;
        n.close = e;
        n.selectItem = s;
        n.move = h;
        o()
    })()
}]);
frameworkModule.controller("PatientNavBarController", ["$scope", "$log", "$filter", "$timeout", "patientTabManager", "patientNav", "appNav", "$state", "sessionCache", "eventAggregator", "patientSvc", "aresDialog", "patientUtil", "loginContext", "officeOptionSvc", "moduleOptionProvider", "$modal", "apptUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) {
    "use strict";
    var k = function(t) {
            var i = null,
                r;
            t && t.patient && (i = t.patient.id || t.id);
            u.activateTab(i);
            u.activeTab ? (angular.forEach(u.tabs, function(n) { n.patient.isActive = n.patient.id == t.patient.id }), n.selectedTab = t, n.$root.containerState.isPatientHostVisible && f.navigateToPatient(i), f.setLastState(null)) : n.$root.containerState.isPatientHostVisible && (r = t, e.switchState(r), f.setLastState(r, !0))
        },
        it = function(n) {
            u.closeTab(n.id);
            nt()
        },
        rt = function() {
            h.subscribe(n, h.events.PatientChanged, g);
            h.subscribe(n, h.events.PatientLoaded, g);
            h.subscribe(n, h.events.PatientDeleted, ut)
        },
        g = function(n, t) {
            u.refreshTab(t);
            $(".patient-nav-container").mCustomScrollbar("update")
        },
        ut = function(n, t, i) {
            u.closeTab(t.id);
            i == "patientHomeView" && nt(function() { u.isEmpty() || e.reload() })
        },
        nt = function(t) {
            r(function() {
                if (n.$root.containerState.isPatientHostVisible = !0, e.goToState("patientHost"), t && t(), u.isEmpty())
                    if (v.isAdminOffice) k("patientRelationship.patientSearch");
                    else if (n.hasMyPatientsPermission) k("patientRelationship.patientSearch");
                else {
                    var i = a.getPatientSearchState();
                    k(i)
                }
            }, 20)
        },
        ft = function(n) {
            y.getOfficeOption(y.optionKeys.IsSpeechCallScreenEnabled).then(function(t) {
                var t = t,
                    r = p.isSpeechCallScreenEnabled(),
                    i;
                r && t ? (i = n.patient, c.getTodayAppts(i.id).success(function(n) {
                    if (n && n.length > 0) {
                        var t = _.sortBy(n, "startTime"),
                            r = _.find(t, function(n) { return b.canCheckIn(n) });
                        r ? a.checkInPatientById(i.id).then(d) : tt(i)
                    } else tt(i)
                })) : (i = n.patient, a.checkInPatientById(i.id).then(d))
            })
        },
        tt = function(n) {
            var t = localStorage.getItem("patientCheckin_Show"),
                i;
            t ? t == "yes" ? a.createFollowUpApptByPatientId(n.id).then(function(t) { b.checkInApptById(t.id, null, n).then(function() {}) }) : a.checkInPatientById(n.id).then(d) : (i = { isSelected: !1, optionName: "下次不再提醒", isReturn: !0 }, l.customConfirmOptionDialog("挂号", "前台已启用排队叫号功能，为了使就诊叫号更准确，建议先创建预约", "是", "否", i).then(function(t) {
                t.isSelected && localStorage.setItem("patientCheckin_Show", "yes");
                a.createFollowUpApptByPatientId(n.id).then(function(t) { b.checkInApptById(t.id, null, n).then(function() {}) });
                window.Ares3 && Ares.sensors.track("NewAppointmentCreate", { OperationType: "新建预约", OperationMode: "患者中心-快速挂号-叫号提醒" })
            }, function(t) {
                t.isSelected && localStorage.setItem("patientCheckin_Show", "no");
                a.checkInPatientById(n.id).then(d)
            }))
        },
        d = function(n) { n && !n.isHideMsg && l.info("提示", "挂号成功！") },
        ot = function() {},
        et = function() {
            n.$watch(function() { return o.params.patientId }, function(n) {
                var i, t, r, f, e;
                n && (i = s.getCache(s.keys.PatientTabState), t = i.loadObject(), _.isArray(t) || (t = []), r = _.find(t, function(t) { return t.patientId === parseInt(n) }), _.each(t, function(n) { n.active = !1 }), r ? r.active = !0 : (f = u.findMenuByWindowLocation(), e = { patientId: parseInt(o.params.patientId), activeMenuId: f ? f.id : "record", active: !0 }, t.push(e)), i.saveObject(t), u.initTab())
            })
        };
    (function() {
        n.isAdminOffice = v.isAdminOffice;
        n.hasMyPatientsPermission = v.providerJob == "网电营销" && !v.isGroup;
        n.patientTabManager = u;
        n.selectTab = k;
        n.closeTab = it;
        n.checkInPatient = ft;
        rt();
        et()
    })()
}]);
frameworkModule.controller("ShenzhenHealthCtrl", ["$log", "$modal", "$scope", function() {
    (function() {})()
}]);
frameworkModule.controller("AresSpeechCallPatientCtrl", ["$log", "$modal", "$scope", "dataDicSvc", "appNavItemProvider", "permissionProvider", "eventAggregator", "userOptionSvc", "officeSvc", "messengerSvc", "$interval", function(n, t, i, r, u, f, e, o, s, h, c) {
    var l = function() {
        h.initConnection(!0);
        c(function() { h.isConnected() || (h.closeConn(), h.initConnection(!0)) }, 12e4)
    };
    (function() { l() })()
}]);
frameworkModule.service("appNavItemProvider", ["$log", "$state", "$q", "$rootScope", "loginContext", "permissionProvider", "moduleOptionProvider", "dashboardSvc", "officeOptionSvc", "officeUtil", "localCache", "enums", "systemOptionSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a) {
    "use strict";
    var v = function(n, t, i, r, u, f) {
            this.id = n;
            this.text = t;
            this.className = i || "icon-puzzle";
            this.permissionCode = r != undefined && r != "" ? r : n;
            this.isVisible = u != undefined ? u : !0;
            this.isActive = !1;
            this.parent = null;
            this.subItems = null;
            this.allowedSubItems = null;
            this.hasVisibleSubItem = !1;
            this.param = f != undefined ? f : null;
            this.allowAnoymous = r === null
        },
        k;
    v.prototype = {
        add: function(n) {
            n.parent = this;
            this.subItems == null && (this.subItems = []);
            this.subItems.push(n)
        },
        addBatch: function(n) {
            var t = this;
            angular.forEach(n, function(n) { t.add(n) })
        },
        setAllowedSubItem: function(n) {
            this.allowedSubItems = n.length > 0 ? n : null;
            (this.allowedSubItems == null || this.allowedSubItems.length == 0) && (this.isVisible = this.allowAnoymous ? !0 : this.subItems != null && this.subItems.length > 0 ? !1 : p(this));
            this.allowedSubItems && (this.hasVisibleSubItem = this.allowedSubItems.some(function(n) { return n.isVisible }))
        }
    };
    var y = function() { return u.dashboardType === "Inventory" ? new v("new", "我的工作", "iconfont icon-wodegongzuo", null, !0, { route: "supplychain.dashboard" }) : new v("dashBoard", "今日工作", "icon-grid", null) },
        d = function() { return new v("patientHost", "患者中心", "icon-user", "patientMgmt.browse|patientMgmt.heathInsurance|patientMgmt.examination|patientMembership.browse|patientCharge.history|patientMgmt.apptRecord|patientMgmt.diagnoseRecord|patientMgmt.txplan|patientMgmt.consultRecord|patientMgmt.orthdontic|patientMgmt.revisitRecord|patientImaging.list|patientDocument.list|generalExam.history|perioExam.history|patientFollowup.history|patientOutProcess.history|patientPrescription.history|patientLisOrder.history|patientMedicalRecord.list") },
        g = function() {
            var r = new v("scheduleCenter", "预约中心", "icon-calendar"),
                n = new v("scheduleCenter.calendar", "预约视图", "icon-puzzle", "scheduleCenter.calendar"),
                t, i;
            return u.doctorId ? (n.id = "scheduleCenter.doctorWeek", n.param = { doctorId: u.doctorId }) : u.consultantId && e.isConsultantDiagnoseOpen() && (n.id = "scheduleCenter.consultantWeek", n.param = { consultantId: u.consultantId }), n.add(new v("scheduleCenter.doctorWeek", "", "", "scheduleCenter.calendar")), n.add(new v("scheduleCenter.consultantWeek", "", "", "scheduleCenter.calendar")), n.add(new v("scheduleCenter.doctorDay", "", "", "scheduleCenter.calendar")), n.add(new v("scheduleCenter.calendar", "", "", "scheduleCenter.calendar")), n.add(new v("scheduleCenter.week", "", "", "scheduleCenter.calendar")), t = [], u.isGroup ? (n = new v("scheduleCenter.groupCalendar", "预约视图", "icon-puzzle", "scheduleCenter.calendar"), t = new v("apptMgmt.groupApptList", "预约查询", "icon-puzzle", "scheduleCenter.search", !0, { isCreateTime: !1 })) : t = new v("apptMgmt.apptList", "预约查询", "icon-puzzle", "scheduleCenter.search", !0, { isCreateTime: !1 }), i = [n, t], i.push(new v("apptMgmt.weixinApplyList", "网络预约", "icon-puzzle", "scheduleCenter.weixinApplyList")), r.addBatch(i), r
        },
        nt = function() {
            var i = new v("managementCenter", "管理中心", "icon-book-open"),
                t = new v("providerSettings", "员工管理", "", "^"),
                n;
            return t.add(new v("providerSettings.providerList", "员工列表", "", "setting.provider")), t.add(new v("providerSettings.providerEdit", "员工信息编辑", "", "setting.provider")), t.add(new v("providerSettings.role", "角色管理", "", "setting.role")), t.add(new v("providerSettings.chargeDeductionHandOver", "划扣交接", "", "setting.chargeDeductionHandOver")), t.add(new v("providerSettings.patientHandOver", "人员交接", "", "setting.patientHandOver")), n = [t, new v("patientCenter.patientList", "患者管理", "icon-puzzle", "patientCenter.allPatients|patientCenter.duplicatedPatient|patientCenter.archivedPatient"), new v("scheduleRule", "排班考勤", "", "schedule.rule|schedule.attendanceConfig|schedule.doctor|schedule.tenant|schedule.attendanceList"), new v("shortMessage", "短信中心", "", "shortMessage.list|shortMessage.history|shortMessage.batch|shortMessaage.reply|shortMessage.charge|shortMessage.shortMessageTemplateConfig|shortMessage.statistics"), new v("new", "医患沟通", "icon-puzzle", "pdCommunication.video", !0, { route: "managementCenter.patientVideo" }), new v("membershipCenter", "会员管理", "icon-puzzle", "membership.list|membership.transaction|membership.categroy|membership.point|membership.discount|membership.cardDetail"), new v("medicalrecordCenter", "病历管理", "icon-puzzle", "patientCenter.emrSearch")], u.providerJob === "医生" && n.push(new v("pendingMedicalrecord", "待办病历", "", null)), n = n.concat([new v("followupCenter", "随访管理", "icon-puzzle", "followup.list|followup.content|followup.result|followup.config|followup.rule"), new v("tagCenter", "标签管理", "icon-puzzle", "managementCenter.tagCenter"), new v("expendCenter", "支出管理", "icon-puzzle", "expendCenter.list"), new v("workflowManagement", "审批管理", "icon-puzzle", "workflowManagement.approval"), new v("groupRevisitCenter", "回访管理", "icon-puzzle", "ReturnVisitFolder.list|patientMgmt.autoRevisitRule"), new v("importCenter", "数据导入", "icon-puzzle", "dataImport.patient|customerClueManagement.import|dataImport.chargeItem")]), (e.isHealthBureauDataExportEnabled() || e.isBizDataBackupEnabled() || e.isHealthBureauDataExportEnabled_Shenzhen()) && n.push(new v("exportCenter", "数据导出", "icon-puzzle", "dataExport.healthBureauDataExport|dataExport.bizDataBackup")), e.isAdminOfficeOpen() && n.push(new v("orgchainCenter", "连锁管理", "icon-puzzle", "organizationManagement.baseData")), e.isNewDentalLabEnabled() || n.push(new v("outprocessCenter", "技加工", "icon-puzzle", "managementCenter.outprocess")), e.isInvoiceEnabled() && n.push(new v("invoiceCenter", "发票管理", "icon-puzzle", "invoice.mgmt")), n.push(new v("consultCenter", "咨询管理", "icon-puzzle", "consultCenter.list|consultCenter.consultList|consultCenter.willingParties")), Ares.isDebugEnabled() && n.push(new v("organizationCenter", "组织管理", "icon-puzzle", null)), n.push(new v("memo", "备忘管理", "icon-puzzle", "memoManagement.record")), n.push(new v("complaint", "投诉管理", "icon-puzzle", "complaintManagement.list")), u.isGroup && n.push(new v("customerClue", "线索管理", "icon-puzzle", Ares.isDebugEnabled ? null : "customerClueManagement.management")), e.isReferralEnabled() && n.push(new v("referralCenter", "推荐管理", "icon-puzzle", "referralCenter.all")), e.isNewMedicalExamEnabled() && n.push(new v("medicalExam", "检查申请", "icon-puzzle", "medicalExam.applicationList")), n.push(new v("pttCenter", "预检分诊", "icon-puzzle", "precheckTriage.view")), i.addBatch(n), i
        },
        gt = function() {
            var u = new v("inventoryCenter.inOrder", "入库管理", "", "inventoryOperation.stockInBrowser"),
                i, r, n, t, f, o;
            return u.add(new v("inventoryCenter.inOrder.productIn", "入库管理", "", "inventoryOperation.stockInBrowser")), u.add(new v("inventoryCenter.inOrder.detail", "入库明细查询", "", "inventoryOperation.stockInBrowser")), i = new v("inventoryCenter.outOrder", "出库管理", "", "inventoryOperation.stockOutBrowser"), i.add(new v("inventoryCenter.outOrder.productOut", "出库管理", "", "inventoryOperation.stockOutBrowser")), i.add(new v("inventoryCenter.outOrder.detail", "出库明细查询", "", "inventoryOperation.stockOutBrowser")), r = new v("inventoryCenter.tradeOrder", "采购管理", "", "procurement.procurementViewPayOrder|procurement.procurementViewPlan"), r.add(new v("inventoryCenter.tradeOrder.procurementPlan", "采购计划", "", "procurement.procurementViewPlan")), r.add(new v("inventoryCenter.tradeOrder.procurementOrder", "采购订单", "", "procurement.procurementViewPayOrder")), n = new v("inventoryCenter.mgmt", "库存管理", "", "inventoryBrowse.stockStatus|inventoryOperation.stockCheck|inventoryOperation.stockTransferBrowser"), n.add(new v("inventoryCenter.mgmt.productList", "库存一览", "", "inventoryBrowse.stockStatus")), n.add(new v("inventoryCenter.mgmt.transferList", "库存调拨", "", "inventoryOperation.stockTransferBrowser")), n.add(new v("inventoryCenter.mgmt.check", "库存盘点", "", "inventoryOperation.stockCheck")), n.add(new v("inventoryCenter.mgmt.stockRemind", "库存预警", "", "inventoryBrowse.stockStatus")), n.add(new v("inventoryCenter.mgmt.expirationRemind", "有效期预警", "", "inventoryBrowse.stockStatus")), t = new v("inventoryCenter.config", "基础数据管理", "", "product.productInfo|warehouse.warehouseManagement"), t.add(new v("inventoryCenter.config.product", "物品一览", "", "product.productInfo")), t.add(new v("inventoryCenter.config.item", "物品管理", "", "product.productInfo")), t.add(new v("inventoryCenter.config.warehouse", "仓库管理", "", "warehouse.warehouseManagement")), t.add(new v("inventoryCenter.config.supplier", "供应商管理", "", "product.supplierInfo")), t.add(new v("inventoryCenter.config.systemitem", "基础数据配置", "", "product.productInfo")), f = new v("inventoryCenter", "库存中心", "icon-note"), o = [n, r, u, i, t], e.isInventoryTakeWorkflowEnabled() && o.push(new v("inventoryCenter.myApply", "领用", "", "Application.fillApplication")), f.addBatch(o), f
        },
        b = function() {
            var i = new v("supplychain.product", "物品", "", "product.productInfo|product.supplierInfo"),
                n, f, t, r;
            return i.add(new v("supplychain.product.list", "物品管理", "", "product.productInfo")), i.add(new v("supplychain.product.category", "大类管理", "", "product.productInfo")), i.add(new v("supplychain.product.producter", "品牌管理", "", "product.productInfo")), i.add(new v("supplychain.product.supplier", "供应商管理", "", "product.supplierInfo")), i.add(new v("supplychain.product.unit", "单位管理", "", "product.productInfo")), n = new v("supplychain.inventory", "仓库", "", "inventoryBrowse.stockStatus|inventoryOperation.stockInBrowser|inventoryOperation.stockTransferBrowser|inventoryOperation.stockCheck|inventoryOperation.stockOutBrowser|warehouse.warehouseManagement"), n.add(new v("supplychain.inventory.manage", "库存管理", "", "inventoryBrowse.stockStatus")), n.add(new v("supplychain.inventory.inorder", "入库管理", "", "inventoryOperation.stockInBrowser")), n.add(new v("supplychain.inventory.outorder", "出库管理", "", "inventoryOperation.stockOutBrowser")), n.add(new v("supplychain.inventory.transfer", "调拨管理", "", "inventoryOperation.stockTransferBrowser")), n.add(new v("supplychain.inventory.check", "盘点管理", "", "inventoryOperation.stockCheck")), f = new v("supplychain.procurement", "采购", "", "procurement.procurementViewPayOrder|procurement.procurementViewPlan|procurement.procurementViewAssistant|procurement.procurementManageOfficeApply|procurement.supplierSettlement"), u.isGroup ? (t = [f], e.isGroupInventoryEnabled() && t.push(n), t.push(i), u.isRootGroup && e.isInventoryTakeWorkflowEnabled() && t.push(new v("supplychain.myApply", "领用", "", "Application.fillApplication")), r = new v("supplychain", "进销存", "icon-support"), r.addBatch(t), r) : (t = [f, n, i, ], e.isInventoryTakeWorkflowEnabled() && t.push(new v("supplychain.myApply", "领用", "", "Application.fillApplication")), r = new v("supplychain", "进销存", "icon-support"), r.addBatch(t), r)
        },
        tt = function() {
            var i = new v("setting", "系统配置", "icon-settings"),
                n = new v("officeSettings", "诊所配置", "", "setting.office"),
                t;
            return n.add(new v("officeSettings.info", "诊所基本信息", "", "setting.office")), n.add(new v("officeSettings.edit", "诊所基本信息编辑", "", "setting.office")), n.add(new v("officeSettings.workflow", "工作流程管理", "", "setting.office")), n.add(new v("officeSettings.officeList", "连锁门诊管理", "", "tenantSettings.office")), n.add(new v("officeSettings.todaywork", "今日工作配置", "", "setting.office")), n.add(new v("officeSettings.supplyChain", "供应链配置", "", "setting.office")), n.add(new v("officeSettings.freeFieldConfig", "自由项配置", "", "setting.office")), n.add(new v("officeSettings.baseDataConfig", "基础数据配置", "", "setting.office")), t = [n, new v("setting.systemsettingBrowser", "基础项目配置", "", "setting.systemsetting"), new v("setting.systemsettingEdit", "基础项目编辑", "", "setting.systemsetting", !1), new v("setting.appt", "预约项目配置", "", "setting.appointment"), new v("setting.emr", "病历配置", "", "setting.emrtemplate"), new v("setting.charge", "收费项目配置", "", "setting.chargeitemBrowse"), new v("setting.diagnosisBrowser", "诊断项目配置", "", "setting.diagnosis"), new v("setting.diagnosisEdit", "诊断项目编辑", "", "setting.diagnosis", !1), new v("setting.operatoryBrowser", "诊室信息配置", "", "setting.operatory"), new v("setting.operatoryEdit", "诊室信息编辑", "", "setting.operatory", !1), new v("workflowSetting", "流程配置", "", "setting.approval"), ], e.enableOrthdonticModule() && t.push(new v("orthdontic.settings", "正畸配置", "", "setting.orthdontic")), t.push(new v("setting.apptInventory", "集成配置", "", "setting.integration")), i.addBatch(t), i
        },
        it = c.getCacheKey(c.keys.IsNewFinanceReportEnabled, u.officeId),
        rt = c.getCache(it),
        ut = c.getCacheKey(c.keys.IsNewPerformanceReportEnabled, u.officeId),
        ft = c.getCache(ut),
        et = function(n) {
            var r = new v("reportCenter", "报表中心", "icon-bar-chart"),
                t = [],
                f = n || !!rt.loadValue(),
                i = n || !!ft.loadValue();
            return console.log(i), t.push(new v("operationReport", "运营报表", "", "operation.apptAnalysis|operation.amounttAnalysis|operation.patientSource|operation.patienttAnalysis|operation.analysis|operation.gift|operation.referrer|operation.patientAppt")), n || t.push(new v("finance", "财务对账", "", "managementCenter.accountStatement|finance.checkCalendar|finance.everydayCheck|finance.officeChargeDetail|finance.chargeSummary|finance.chargeDetail|finance.chargeItemDetail|finance.overduePatient|finance.overdueChargeReport|finance.overdueChangeReport|finance.patientConsumption|finance.familyConsumption|finance.membershipSummary|finance.aliPayOrderTransaction|finance.weixinPayOrderTransaction|finance.cashFlow|finance.chargeGroupBuyCertificate|finance.membershipBalance|finance.chargeDiscount|finance.customizeReport|finance.yibaoAccountCheck", !f)), t.push(new v("financev2", "新财务对账", "", "financev2.checkCalendar|financev2.dailyCheckCashflowSummaryReport|financev2.dailyCheckCashflowSummaryByPayeeReport|financev2.dailyCheckCashflowSummaryByDateReport|financev2.dailyCheckCashflowSummaryByDepartmentReport|financev2.dailyCheckCashflowSummaryByItemSuperTypeReport|financev2.dailyCheckCashflowSummaryByFeeTypeReport|financev2.dailyCheckIncomeReport|financev2.dailyCheckBussinessIncomeByDateReport|financev2.dailyCheckBussinessIncomeByItemSuperTypeReport|financev2.dailyCheckBussinessIncomeByFeeTypeReport|financev2.dailyCheckBussinessIncomeByDepartmentReport|financev2.dealDetailByTimeReport|financev2.dealDetailByItemReport|financev2.dealDetailByProviderReport|financev2.dealDetailByPatientReport|financev2.certificateByInventoryReport|financev2.certificateByUsedReport|financev2.membershipBalanceReport|financev2.membershipSummaryReport|financev2.patientPointChangeDetailReport|financev2.patientPointSummaryReport|financev2.yibaoAccountCheckReport|financev2.dailyCheckOverdueReport|financev2.overduePatientReport|financev2.overdueChargeReport|financev2.overdueChangeReport|financev2.familyConsumptionRepot|financev2.consultPerformanceByItemReport|financev2.officeAccountCheckReport|financev2.giftcardBalanceReport|financev2.giftcardBalanceChangeReport|financev2.netflowAmbassadorCheckReport|financev2.netflowAmbassadorTransformAnalysisReport", f)), n || t.push(new v("performance", "绩效管理", "", "performance.doctorChargeDetail|performance.doctorChargeCategroy|performance.doctorVisits|performance.nurseChargeDetail|performance.nurseChargeCategroy|performance.consultantChargeCategory|performance.consultantWorkSummary|performance.assistantWorkSummary|performance.doctorApptPerformance|performance.chargeDeduction|performance.medicalExam|performance.networkConsult|performance.apptTransferred", !i)), t.push(new v("performancev2", "新绩效管理", "", "performancev2.personalPerformanceReport|performancev2.personalPerformanceExport|performancev2.onlineConsultPerformanceSumReport|performancev2.onlineConsultPerformanceByOrderReport|performancev2.doctorPerformanceByItemReport|performancev2.doctorPerformanceByDepartmentReport|performancev2.doctorPerformanceBySuperTypeReport|performancev2.doctorPerformanceByItemTypeReport|performancev2.doctorPerformanceBySubCategoryReport|performancev2.doctorPerformanceByApptCountReport|performancev2.doctorPerformanceByTransferredReport|performancev2.doctorPerformanceByChargeDeductionReport|performancev2.consultPerformanceByItemReport|performancev2.consultPerformanceByDepartmentReport|performancev2.consultPerformanceBySuperTypeReport|performancev2.consultPerformanceByItemTypeReport|performancev2.consultPerformanceBySubCategoryReport|performancev2.consultPerformanceByApptCountReport|performancev2.nursePerformanceByItemReport|performancev2.nursePerformanceByDepartmentReport|performancev2.nursePerformanceBySuperTypeReport|performancev2.nursePerformanceByItemTypeReport|performancev2.nursePerformanceBySubCategoryReport|performancev2.assistantWorkReport|performancev2.accountCheckReport|performancev2.medicalExam|performancev2.doctorApptPerformance", i)), t.push(new v("supplychainReport", "进销存", "", "supplychainReport.overview|supplychainReport.inventorySummary|supplychainReport.purchaseSummary|supplychainReport.takeSummary|supplychainReport.salesSummary|supplychainReport.SupplierSettlementHistory")), t.push(new v("tenantReport", "公司报表", "", "tenantReport.newPatients|tenantReport.incomeSummary|tenantReport.apptTrend|tenantReport.incomeTrend")), e.isCustomMadeReportOpen() && t.push(new v("customMadeReport", "定制报表", "", "customerMadeFolder.otherReport")), u.isTenantAdmin || u.dashboardRoleType == "财务" || t.push(new v("personalperformance", "个人绩效")), t.push(new v("myReport", "报表下载", "", "finance.myReport|myReport.all")), r.addBatch(t), r
        },
        ni = function() {
            var t = new v("marketingCenter", "微诊所管理"),
                n = new v("alipay", "支付宝推广", "", "", !1),
                i;
            return n.add(new v("alipay.clinicsetting", "服务窗诊所设置")), n.add(new v("alipay.doctorsetting", "服务窗医生设置")), n.add(new v("alipay.conversation", "服务窗咨询")), i = [new v("marketingCenter.marketingBrowser", "运营首页"), new v("marketingCenter.contentMarketing", "内容营销", "", "", !1), new v("marketingCenter.menuSetting", "公众号菜单设置", "", "marketingCenter.consultingManagement", !1), new v("marketingCenter.accountSetting", "公众号设置", "", "", !1), new v("marketingCenter.doctorSetting", "医生设置", "", "", !1), new v("marketingCenter.projectManagement", "项目管理", "", "", !1), new v("marketingCenter.contentCreate", "创建图文消息", "", "", !1), new v("marketingCenter.wxAuthorization", "微信授权页面", "", "", !1), new v("marketingCenter.activityManagement.record", "", "", "", !1), new v("marketingCenter.marketingSingleConsult", "患者交流", "", "marketingCenter.consultingManagement", !1), new v("marketingCenter.AuthorizedCheck", "功能检测", "", "", !1), n], t.addBatch(i), t
        },
        ot = function(t) {
            Ares.plugins && angular.forEach(Ares.plugins, function(i) {
                n.info("load menu of plugin " + i.name);
                var r = i.menuInitFn(t, u);
                angular.isArray(r) ? angular.forEach(r, function(n) { n && t.navItems.push(n) }) : r && t.navItems.push(r)
            })
        },
        st = function() { return new v("scrmCenter", "SCRM", "icon-grid", null) },
        ht = function() { return new v("mallCenter", "领健商城", "icon-basket", null) },
        ct = function() { return new v("new", "开放平台", "iconfont icon-pingtaiguanli", null, !0, { route: "enterpriseCenter.services" }) },
        lt = function() {
            var n = new v("inHospitalCenter", "住院管理", "icon-puzzle", null),
                t = [new v("inHospitalCenter.checkInOut", "入院出院", "", null, !1), new v("inHospitalCenter.bedCenter", "床位管理", "", null, !1), new v("inHospitalCenter.patientCenter", "患者管理", "", null, !1), new v("inHospitalCenter.nurseCenter", "护士管理", "", null, !1), new v("inHospitalCenter.doctorCenter", "医生管理", "", null, !1), new v("inHospitalCenter.doctorAdviceCenter", "医嘱管理", "", null, !1)];
            return n.addBatch(t), n
        },
        at = function() {
            var n = new v("securityCenter", "安全管理", "icon-lock"),
                t = [new v("securityCenter.loginLog", "登录日志", "", "security.loginLog"), new v("securityCenter.operationLog", "操作日志", "", "security.operationLog"), new v("securityCenter.dataSetting", "数据安全", "", "security.dataSetting")];
            return e.isDeviceMgmtEnabled() && t.unshift(new v("securityCenter.device", "设备安全", "", "deviceSecurity.management|deviceSecurity.application")), n.addBatch(t), n
        },
        vt = function() {
            var n = new v("cssd", "CSSD", "iconfont icon-xiaodu"),
                t = [new v("cssd.baseData", "基础数据", "", null), new v("cssd.businessCenter", "业务中心", "", null), new v("cssd.borrowLog", "借入借出", "", null), ];
            return n.addBatch(t), n
        },
        yt = function() {
            var n = new v("", "技加工", "iconfont icon-weixiu", "dentalLab.order|dentalLab.product|dentalLab.factory"),
                t = [new v("new", "订单跟踪", "", "dentalLab.order", !0, { route: "dentalLab.orderTrack" }), new v("new", "结算管理", "", "dentalLab.order.completeSettle", !0, { route: "dentalLab.settlement" }), new v("new", "项目维护", "", "dentalLab.product", !0, { route: "dentalLab.product" }), new v("new", "厂商管理", "", "dentalLab.factory", !0, { route: "dentalLab.factory" }), new v("new", "项目导入", "", "dentalLab.product", !0, { route: "dentalLab.import" })];
            return n.addBatch(t), n
        },
        pt = function() {
            var n = new v("others", "其他项", "", "", !1),
                t = [new v("root", "root"), new v("default", "default"), new v("noPermission", "noPermission"), new v("demo", "demo"), new v("AliTurnOn.open", "aliturnon"), new v("systemTool", "systemTool")];
            return n.addBatch(t), n
        },
        wt = function(n) {
            for (var r, t = null, i = 0; i < this.navItems.length; i++)
                if (r = this.navItems[i], t = _.find(r.subItems, function(t) { return t.id == n }), t) break;
            return t
        },
        bt = function() {
            h.isRootGroup().then(function(n) {
                if (u.isGroup && !n && u.isRegularChain) {
                    var t = _.find(w, function(n) { return n.text == "商城" });
                    t && (t.isVisible = !1)
                }
            })
        },
        kt = function() {
            var n = !1;
            return angular.forEach(w, function(i) {
                var r = !1;
                angular.forEach(i.allowedSubItems, function(n) {
                    n.isActive = n.id === "new" ? t.includes(n.id) && t.params && t.params.route && n.param && n.param.route && n.param.route === t.params.route : t.includes(n.id);
                    n.isActive && (i.lastVisitedChild = n);
                    !n.isActive && n.subItems && angular.forEach(n.subItems, function(r) {
                        r.isActive = r.id === "new" ? t.includes(r.id) && t.params && t.params.route && r.param && r.param.route && r.param.route === t.params.route : t.includes(r.id);
                        r.isActive && (i.lastVisitedChild = r);
                        n.isActive |= r.isActive;
                        !n.isActive && r.subItems && angular.forEach(r.subItems, function(u) {
                            u.isActive = t.includes(u.id);
                            u.isActive = u.id === "new" ? t.includes(u.id) && t.params && t.params.route && u.param && u.param.route && u.param.route === t.params.route : t.includes(u.id);
                            u.isActive && (i.lastVisitedChild = u);
                            r.isActive |= u.isActive;
                            n.isActive |= r.isActive
                        })
                    });
                    n.isActive && (_.each(i.allowedSubItems, function(n) { n.expanded = !1 }), n.expanded = !0);
                    r |= n.isActive
                });
                i.isActive = i.id === "new" ? r || i.param.route === "appointment" && t.params && t.params.route && t.params.route.startsWith("appointment") || t.params && t.params.route === i.param.route : r || t.is(i.id);
                i.id === "dashBoard" && (i.isActive = t.includes(i.id));
                n |= i.isActive
            }), n
        },
        dt = function(n) {
            var t = i.defer();
            return n.navItems = _.filter(n.navItems, function(n) { return n && n != null }), f.loadPermissions().then(function() {
                angular.forEach(n.navItems, function(n) {
                    var t;
                    t = n.id === "others" ? n.subItems : _.filter(n.subItems, function(n) {
                        var t = !1,
                            i;
                        return n.permissionCode == "^" && n.subItems && n.subItems.length > 0 ? (i = _.filter(n.subItems, function(n) { return p(n) }), t = i && i.length > 0) : t = p(n), t
                    });
                    n.setAllowedSubItem(t)
                });
                t.resolve()
            }), t.promise
        },
        p = function(n) { return n.allowAnoymous || f.isAllowed(n.permissionCode) },
        w = [];
    (function(n) {
        n.navItems = w;
        n.findNavItem = wt;
        n.initNavItemState = kt
    })(this);
    k = function(n, t) {
        var o = t.isNewOffice,
            i;
        return n.NavItem = v, n.others = pt(), n.patientHost = d(), n.systemSetting = tt(), n.scheduleCenter = g(), n.managementCenter = nt(t), n.reportCenter = et(o), n.navItems.push(n.others), u.isAdminOffice ? (n.navItems.push(y()), n.navItems.push(n.patientHost), e.isNewInventoryOpen() && n.navItems.push(b())) : (u.isGroup ? (i = u.roles.indexOf("网电咨询师") > -1 || u.roles.indexOf("网电主管") > -1, u.dashboardType == "WebPhoneConsultant" || i ? n.navItems.push(y()) : u.dashboardType === "Inventory" && u.isRootGroup && e.isGroupInventoryEnabled() && n.navItems.push(y())) : u.dashboardType && n.navItems.push(y()), n.navItems.push(n.patientHost), n.navItems.push(n.scheduleCenter), e.isInHospitalOpen() && n.navItems.push(lt()), n.navItems.push(n.managementCenter), n.navItems.push(n.reportCenter), n.navItems.push(b()), e.isMallOpen() && f.isAllowed("tradingPlatform.list") && n.navItems.push(ht()), e.isSCRMOpen() && (r.isNewWxEnabled = !0, f.isAllowed("scrmMgmt.loggin") && n.navItems.push(st())), e.isOpenPlatformEnabled() && n.navItems.push(ct()), n.navItems.push(n.systemSetting), n.navItems.push(at()), e.isCssdEnabled() && n.navItems.push(vt()), e.isNewDentalLabEnabled() && n.navItems.push(yt())), ot(n), u.isGroup && bt(n), dt(n)
    };
    this.initialize = function() {
        var n = i.defer(),
            t = this;
        return a.getSystemTempOption(a.optionKeys.IsTempPrecheckTriage).then(function(i) {
            var r = i;
            s.getOfficeOptions([s.optionKeys.PaymentTypeUpgradeStatus, s.optionKeys.IsPrecheckTriageEnabled]).then(function(i) {
                var u = i[0] == l.PaymentTypeUpgradeStatus.InitUpgraded,
                    f = i[1],
                    e = { isNewOffice: u, isTempPrecheckTriage: r, isPrecheckTriageEnabled: f };
                k(t, e).then(function() { n.resolve() })
            })
        }), n.promise
    }
}]);
commonModule.factory("appNav", ["$state", "$location", "$timeout", "$window", "$q", "patientNav", "enums", "functionGuideProvider", "permissionProvider", "patientTabManager", "aresDialog", "loginContext", "systemConfigUtil", "eventAggregator", "ares3StateMapping", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) {
    "use strict";
    var k = 0,
        b = function(t, i, r) {
            var u, f;
            window.Ares3 && (t = y.translate(t));
            u = {};
            r && _.extend(u, r);
            f = null;
            f = _.isFunction(i) ? i() : i;
            n.transitionTo(t, f, u)
        },
        rt = function() { r.history.back() },
        p = function(t, r) {
            window.notDestroyOfShelfInstance = undefined;
            window.Ares3 && (t = y.translate(t) || t);
            var u = n.get(t);
            u && u.aresLastState && t !== "scheduleCenter.groupCalendar" ? (tt(u, r), n.go(u.aresLastState, u.aresLastParams)) : n.go(t, r);
            i(function() { o.showByUri(n.$current.url.sourcePath) }, 1e3)
        },
        w = function(n, t, i) { return n = _.isObject(n) ? n.id : n, g(n), f.navigateToPatient(n, t, i) },
        g = function(n) {
            i(function() {
                var t = "#pid_" + n;
                $(".patient-nav-container").mCustomScrollbar("scrollTo", t)
            }, 1e3)
        },
        ut = function(n) { return w(n, "membership") },
        ft = function(n) { w(n, "patientgeneralMedicalRecords").then(function() { b("patientgeneralMedicalRecords.patientEmr.list", { patientId: n }) }) },
        et = function(n) { w(n, "orthdontic", { patientId: n, orthStateName: "process" }).then(function() { b("patientOrthdontic.process", { patientId: n, orthStateName: "process" }) }) },
        ot = function(n, t) { w(n, "patientgeneralMedicalRecords").then(function() { b("patientMedicalRecord.createRecord", t) }) },
        st = function(n) { w(n, "apptRecord").then(function() { b("patientApptRecord", { patientId: n }) }) },
        ht = function() { p("supplychain.procurement.plan") },
        ct = function(n, t) { w(n, "patientgeneralMedicalRecords").then(function() { b("patientgeneralMedicalRecords.patientEmr.edit", t) }) },
        lt = function(n) { w(n, "consultRecord").then(function() { b("patientConsultRecord", { patientId: n }) }) },
        at = function(n) { w(n, "consultRecord", { patientId: n, isShowPopup: !0 }).then(function() { b("patientConsultRecord", { patientId: n, isShowPopup: !0 }) }) },
        vt = function(n, t, r) { w(n, "followupHistory").then(function() { i(function() { b("patientFollowup.createRecord", { patientId: n, status: t, historyState: r }) }, 500) }) },
        yt = function(n, t) { return w(n, "patientCharge", { apptId: t }) },
        pt = function(n, t, r) { w(n, "patientCharge", { apptId: t }).then(function() { i(function() { b("patientCharge.editSourceOrder", { patientId: n, chargeOrderId: r }) }, 500) }) },
        wt = function(n) { return w(n, "generalExamHistory") },
        bt = function(n, t, i) { return t = t || "imagingHistory", w(n, t, i) },
        kt = function(n) { return w(n, "prescriptionHistory") },
        nt = function(n) { return w(n, "followupHistory") },
        dt = function(n, t, r, u) {
            var f = 1;
            (r == "随访完成" || r == "已取消" || r == "未成功") && (f = 2);
            nt(n).then(function() { i(function() { b("patientFollowup.createRecord", { patientId: n, followupId: t, status: f, historyState: u }) }, 500) })
        },
        gt = function(n, t, i) { b("patientgeneralMedicalRecords.patientTxplan.list", { patientId: n, txplanItemId: t, txplanStatus: i }) },
        ni = function(n, t) { b("patientgeneralMedicalRecords.patientTxplan.create", { patientId: n, txplanItemId: t }) },
        ti = function(n, t, i) { var r = u.defer(); return b("patientgeneralMedicalRecords.patientTxplan.list", { patientId: n, txplanItemId: t, txplanStatus: i }), r.resolve(!0), r.promise },
        ii = function(n, t, i) { return t = t || "patientDocumentHistory", w(n, t, i) },
        ri = function(n) { return w(n, "outprocessHistory") },
        ui = function(n, t, i) {
            var r = { apptId: t, day: i };
            l.isGroup ? p("scheduleCenter.groupCalendar", r) : p("scheduleCenter.calendar", r)
        },
        fi = function(n) {
            var t = { day: n };
            p("scheduleCenter.week", t)
        },
        ei = function(n, t) {
            var i = { doctorId: n, day: t };
            p("scheduleCenter.doctorWeek", i)
        },
        oi = function(n, t) {
            var i = { consultantId: n, day: t };
            p("scheduleCenter.consultantWeek", i)
        },
        si = function(n, t) {
            var i = { doctorId: n, day: t };
            p("scheduleCenter.doctorDay", i)
        },
        hi = function(n) {
            var t = { patientId: n };
            p("shortMessage.history", t)
        },
        ci = function() { p("patientCenter.todayPatientList") },
        li = function() { p("tenantSettings") },
        ai = function() { p("dashBoard") },
        vi = function() { var n = u.defer(); return p("dashBoard"), n.resolve(!0), n.promise },
        yi = function() { p("officeSettings.info") },
        pi = function() { p("officeSettings.point") },
        wi = function() { p("new", { route: "enterpriseCenter.overview" }) },
        bi = function() { p("new", { route: "enterpriseCenter.software" }) },
        ki = function() { p("shortMessage.charge", { isExchangeCredits: !0 }) },
        di = function() { p("new", { route: "managementCenter.patientVideo" }) },
        gi = function() {
            var n = "reportCenter.patient";
            s.isAllowed("operation.patienttAnalysis|tenantReport.newPatients|operation.referrer|operation.patientSource") ? n = "reportCenter.patient" : s.isAllowed("operation.apptAnalysis|tenantReport.apptTrend|operation.patientAppt") ? n = "reportCenter.appointment" : s.isAllowed("operation.gift") ? n = "reportCenter.marketing" : s.isAllowed("operation.amounttAnalysis|tenantReport.incomeSummary|tenantReport.incomeTrend") ? n = "reportCenter.revenue" : s.isAllowed("operation.analysis") && (n = "reportCenter.operation");
            p(n)
        },
        nr = function(n, i) { i ? t.path(n).search(i) : t.path(n).search({}) },
        tr = function(n) {
            var t = { procurementPayOrderId: n.id };
            p("inventoryCenter.inOrder.inTradeOrder", t)
        },
        ir = function(n, t, i) {
            i ? w(n, "patientCharge").then(function() { b("patientCharge.editSourceOrder", { patientId: n, chargeOrderId: t }) }) : a.getConfigValue("YibaoType", null).then(function(i) {
                if (i) {
                    var r = i.toLowerCase();
                    w(n, "patientCharge").then(function() { b("patientCharge.editYibaoOrder", { patientId: n, yibaoType: r, chargeOrderId: t }) })
                }
            })
        },
        rr = function() {
            var t = n.current.name;
            n.reload(t)
        },
        ur = function(n, t, i) { tt(t, i) },
        tt = function(t, i) {
            var r, f, u;
            t.name.length > 10 && (r = t.name.split("."), r.length > 1 && (r.pop(), f = r.join("."), u = n.get(f), u && (u.aresLastState = t, u.aresLastParams = i)))
        },
        fr = function(n, t) {
            k = 0;
            it(n, t)
        },
        it = function(t, r) {
            var u = n.current,
                f = k == 0 ? 3e3 : 100;
            k < 20 && u.name != t && i(function() {
                k++;
                b(t, r);
                it(t, r)
            }, f)
        },
        er = function(n, t, i, r, u) { return f.confirmLeave(n, t, i, r, u) },
        or = function(n, t, i, r, u) {
            if (cr(t)) {
                var f = parseInt(i.patientId || 0);
                f && !s.canViewPatient(f) ? (n.preventDefault(), s.checkPatientPermission(f).then(function(e) { e === !0 ? d(n, t, i, r, u) : (h.closeTab(f), c.info("提示", "当前用户没有权限访问该患者！")) })) : d(n, t, i, r, u)
            } else d(n, t, i, r, u)
        },
        sr = function(t) {
            t = t || n.current;
            t._hasConfirmed = !0
        },
        d = function(t, i, r, u) {
            u._hasConfirmed = !0;
            t.defaultPrevented === !0 && n.go(i, r)
        },
        hr = function(n, t) { vi().then(function() { i(function() { t ? p("dashBoard.appointApply", { status: n, apptApplyId: t }) : p("dashBoard.appointApply", { status: n }) }, 1e3) }) },
        cr = function(n) { var t = n.name.indexOf("patientCenter") != 0 && n.name.indexOf("patient") == 0; return n.name == "patientHost" && h.tabs.length == 0 && (t = !1), t },
        lr = function(n, t, i, r, u, f, e, o, s, h) {
            this.name = n;
            this.text = t;
            this.className = i;
            this.permissionCode = r || null;
            this.subStates = u || null;
            this.checkIsShowMethod = _.isFunction(f) ? f : function() { return !0 };
            this.isNewTab = e;
            this.hint = o;
            this.isDisabled = s;
            this.navParams = h
        };
    return { switchState: b, switchStateEx: fr, goToState: p, goBack: rt, goToPatient: w, goToMembership: ut, goToEMR: ft, goToOrthdonticProcess: et, goToCharge: yt, goToHardTissue: wt, goToScheduler: ui, goToSchedulerWeek: fi, goToDoctorWeek: ei, goToConsultantWeek: oi, goToDoctorDay: si, goToShortMessageHistory: hi, goToTodayPatient: ci, goToTenantSetting: li, goToDashboard: ai, goToUrl: nr, goToImaging: bt, goToPrescription: kt, goToPatientDocument: ii, goToOutprocess: ri, goToFollowup: nt, goToFollowupDetail: dt, reload: rr, onStateChanged: ur, goTxplan: gt, goToCreateTxplan: ni, goTxplanSync: ti, TabItem: lr, goToCreateEMR: ot, goToCreateFollowup: vt, goToOfficeInfo: yi, goToEditEMR: ct, scrollToPatient: g, confirmLeave: er, confirmEnter: or, allowLeave: sr, goToProcurementPlan: ht, goToInTradeOrder: tr, goToApptRecord: st, goToYibaoCharge: ir, goToConsultRecord: lt, goToAddConsult: at, goToOfficeCredits: pi, goToShortMessage: ki, goToPatientVideo: di, goToChargeDetail: pt, goToEnterpriseCenter: wi, goToEnterpriseApplications: bi, goToDashBoardApply: hr, goToOperationReport: gi }
}]);
commonModule.factory("ares3StateMapping", [function() {
    var n = { "patientCenter.patientList.search": "patientRelationship.patientSearchHome", "patientCenter.patientList.duplicated": "newPatientManagement.duplicate.list", "patientCenter.patientList.archived": "newPatientManagement.archived.list", "providerSettings.providerList": "officeManagement.staff.list", "providerSettings.providerEdit": "officeManagement.staff.edit", "providerSettings.role": "officeManagement.staff.role", "providerSettings.patientHandOver": "officeManagement.handover.patient", "providerSettings.chargeDeductionHandOver": "officeManagement.handover.chargeDeduction", "scheduleRule.doctorSchedule": "officeManagement.schedule.doctor", "scheduleRule.tenantSchedule": "officeManagement.schedule.tenant", "scheduleRule.attendanceList": "officeManagement.schedule.attendanceList", "scheduleRule.attendanceDayList": "officeManagement.schedule.attendanceDayList", "workflowManagement.approval": "officeManagement.businessRule.workflowApproval", "officeSettings.officeList": "officeManagement.orgchain.offices", "orgchainCenter.baseData": "officeManagement.orgchain.baseData", "orgchainCenter.bizData": "officeManagement.orgchain.businessData", "securityCenter.loginLog": "officeManagement.security.account", "securityCenter.dataSetting": "officeManagement.security.data", "securityCenter.operationLog": "officeManagement.security.operationLog", "shortMessage.dashboard": "officeManagement.sms.dashboard", "shortMessage.history": "officeManagement.sms.history", "shortMessage.batch": "officeManagement.sms.batch", "shortMessage.feedback": "officeManagement.sms.reply", "shortMessage.charge": "officeManagement.sms.charge", "shortMessage.statistics": "officeManagement.sms.statistics", "shortMessage.config": "officeManagement.sms.autoRule", "membershipCenter.list": "marketingManagement.member.list", "membershipCenter.levelApply": "marketingManagement.member.levelApply", "membershipCenter.typeTransactionList": "marketingManagement.member.changeLog", "membershipCenter.giftCertificateDetail": "marketingManagement.giftCard.detail", "membershipCenter.giftCertificateList": "marketingManagement.giftCard.discount", "membershipCenter.giftCard": "marketingManagement.giftCard.bearer", "setting.apptInventory.itemMapping": "marketingManagement.appointmentChannel.mapping", "setting.apptInventory.baseSetting": "marketingManagement.appointmentChannel.baseSetting", "setting.apptInventory.inventorySetting": "marketingManagement.appointmentChannel.inventorySetting", "referralCenter.dashboard": "marketingManagement.referralSummary.dashboard", "referralCenter.patientReferralReport": "marketingManagement.referralDetail.referer", "referralCenter.patientReferralVisitReport": "marketingManagement.referralDetail.referee", "referralCenter.patientVisitReferralRewardReport": "marketingManagement.referralReward.arrival", "referralCenter.patientPaymentReferralRewardReport": "marketingManagement.referralReward.consumption", "referralCenter.patientTotalPaymentReferralRewardReport": "marketingManagement.referralReward.consumptionSum", "supplychain.inventory.manage.traceability": "supplychain.traceability", "followupCenter.list": "newPatientManagement.followup.list", "followupCenter.last": "newPatientManagement.followup.last", "groupRevisitCenter.list": "newPatientManagement.revisit.list", "consultCenter.networkList": "newPatientManagement.consult.networkList", "consultCenter.list": "newPatientManagement.consult.list", "consultCenter.sceneConsultList": "newPatientManagement.consult.onSiteList", "operationReport.patient": "reportCenter.patient.summary", "tenantReport.newPatient": "reportCenter.patient.newPatient", "operationReport.referrer": "reportCenter.patient.referrer", "operationReport.patientSource": "reportCenter.patient.source", "operationReport.patientConsumption": "reportCenter.patient.consumption", "operationReport.appointment": "reportCenter.appointment.summary", "tenantReport.apptTrend": "reportCenter.appointment.trend", "operationReport.patientApptV2": "reportCenter.appointment.attendance", "operationReport.giftAuditLog": "reportCenter.marketing.gift", "operationReport.amount": "reportCenter.revenue.summary", "tenantReport.incomeSummary": "reportCenter.revenue.incomeSummary", "tenantReport.incomeTrend": "reportCenter.revenue.incomeTrend", "operationReport.statistics": "reportCenter.operation.analysis", "performancev2.medicalExamView": "reportCenter.performance.medicalExam", "financev2.check-calendar": "reportCenter.financeCalendar.calendar", "financev2.overduePatient": "reportCenter.overduePatient.report", "financev2.familyConsumption": "reportCenter.familyConsumption.report", "myReport.backgroundReport": "reportCenter.mine.offline", "performancev2.assistantWork": "reportCenter.assistantWork.report", "performancev2.apptPerformance": "reportCenter.apptPerformance.report", "officeSettings.patientRequired": "systemSetting.patientField.newPatient", "officeSettings.onlineConsultCreateRequired": "systemSetting.patientField.onlineConsultant", "officeSettings.checkInRequired": "systemSetting.patientField.checkInSetting", "tagCenter.patienttag": "systemSetting.patientTag.management", "followupCenter.template": "systemSetting.patientFollowup.template", "followupCenter.content": "systemSetting.patientFollowup.contentTemplate", "followupCenter.result": "systemSetting.patientFollowup.resultTemplate", "followupCenter.autoRule": "systemSetting.patientFollowup.autoRule", "referralCenter.arrivalReferralConfig": "systemSetting.marketingReferral.arrival", "referralCenter.paymentReferralConfig": "systemSetting.marketingReferral.payment", "referralCenter.totalPaymentReferralConfig": "systemSetting.marketingReferral.totalPayment", "membershipCenter.membershipTypeList": "systemSetting.memberTypes.management", "officeSettings.membershipCardNumConfig": "systemSetting.memberTypes.cardNumberConfig", "<membership-point-view><\/membership-point-view>": "systemSetting.memberTypes.point", "groupRevisitCenter.autoRevisitRule": "systemSetting.patientRevisit.autoRule", "consultCenter.intention": "systemSetting.patientConsultant.intention", "officeSettings.supplyChain": "systemSetting.supplychainRule.management", "setting.diagnosisBrowser.diagnose": "systemSetting.medicalDiagnosis.management", "setting.diagnosisBrowser.treatmentplan": "systemSetting.medicalDiagnosis.treatmentPlan", "setting.emr.config": "systemSetting.medicalRecord.settings", "setting.emr.templateBrowser": "systemSetting.medicalRecord.template", "setting.emr.templateItemSetting": "systemSetting.medicalRecord.templateItem", "scheduleRule.rule": "systemSetting.staffManagement.scheduleSetting", "scheduleRule.attendanceConfig": "systemSetting.staffManagement.attendanceSetting", "officeSettings.dentalLabSetting": "systemSetting.dentalLab.settings", "workflowSetting.approval": "systemSetting.businessManagement.approvalSetting", "officeSettings.invoice": "systemSetting.officeManagementMisc.invoice", "setting.operatoryBrowser": "systemSetting.officeManagementMisc.operatory", "officeSettings.workflow": "systemSetting.officeManagementMisc.businessRule", "setting.systemsettingBrowser": "systemSetting.officeManagementMisc.systemSetting", "officeSettings.freeFieldConfig": "systemSetting.officeManagementMisc.freefieldSetting", "officeSettings.todaywork": "systemSetting.officeManagementMisc.workbenchSetting", "officeSettings.callingConfig": "systemSetting.officeManagementMisc.calling", "officeSettings.permissionConfig": "systemSetting.officeManagementMisc.permissionSetting", "officeSettings.chargeRequired": "systemSetting.chargeField.setting", "setting.charge.itemBrowser": "systemSetting.chargeItem.setting", "officeSettings.baseDataConfig": "systemSetting.chargeItem.requirement", "importCenter.chargeitem": "systemSetting.chargeItem.import", "setting.charge.itemFreeField": "systemSetting.chargeItem.freefield", "setting.charge.chargeType": "systemSetting.chargeItem.chargeType", "setting.charge.category": "systemSetting.chargeItem.chargeCategory", "setting.charge.deductionPlan": "systemSetting.chargeItem.deductionPlan", "setting.charge.package": "systemSetting.chargeItem.chargePackageSetting", "setting.charge.paymentType": "systemSetting.chargePayment.method", "setting.charge.lcPayGateway": "systemSetting.chargePayment.lcPayGateway", "financev2.dealDetailReportSet": "financev2.dealDetailReportSetV3" },
        t = function(t) { var i = n[t]; return i ? i : t };
    return { translate: t }
}]);
frameworkModule.factory("patientNav", ["$log", "$q", "$location", "$state", "$timeout", "patientTabManager", "appNavItemProvider", "aresDialog", "eventAggregator", function(n, t, i, r, u, f, e, o, s) {
    var c = function(n) { return !_.isUndefined(n) && !_.isNull(n) && n !== "" },
        y = function(n) {
            this.patientId = n.patientId;
            this.needActivate = n.needActivate === !0;
            this.param = n.param || null;
            this.action = c(n.action) ? n.action : null;
            this.navParam = n.navParam || null
        },
        p = function(n) { if (n || (n = f.getActiveTab()), !n) return null; return n.getActiveMenu() },
        h = function(n, t) {
            t ? i.path(n).search(t) : i.path(n).search({});
            f.backupTab()
        },
        l = function(n, i, r) {
            console.log(i);
            var u = t.defer(),
                e = { patientId: n, menuId: i };
            return v(null, e, r, null, null).then(function() {
                if (i == "membershipS") {
                    window.open("ssss/sss.html", '_blank');
                } else {
                    f.loadTab(n).then(function(t) {
                        var e, s;
                        f.activateTab(t.id);
                        i ? (t.activateMenu(i), angular.forEach(t.showUserMenus, function(n) { n.active = n.id == i })) : t.menus.length > 0 ? (e = _.any(t.menus, function(n) { return n.active == !0 }), e || (t.menus[0].active = !0)) : o.info("提示", "当前用户没有权限访问该患者！");
                        s = t.getActiveMenu();
                        h(s.routeUrl, r);
                        a(1e3, n).then(function() { u.resolve(t) }, function() { a(1e3, n).then(function() { u.resolve(t) }) })
                    })
                }

            }), u.promise
        },
        w = function(n) { n && n.patientTab && l(n.patientTab.id, n.id) },
        a = function(n, i) {
            var r = t.defer();
            return u(function() {
                var n = f.getActiveTab();
                n && n.id == i ? r.resolve(n) : r.reject(n)
            }, n), r.promise
        },
        v = function(n, i, u, f) {
            var h = t.defer(),
                e = f || r.current,
                c, l;
            if (e.name == "patientgeneralMedicalRecords.patientEmr.edit" || e.name == "patientOrthdontic.processEdit" || e.name == "groupRevisitCenter.autoRevisitRule")
                if (e._hasConfirmed) h.resolve(!0);
                else {
                    n && n.preventDefault();
                    c = "您正在编辑病历，确认离开？";
                    l = !0;
                    switch (e.name) {
                        case "patientOrthdontic.processEdit":
                            c = "您正在编辑正畸过程，确认离开";
                            l = !1;
                            break;
                        case "groupRevisitCenter.autoRevisitRule":
                            c = "编辑数据没有保存，离开此界面编辑数据将丢失，确认离开？";
                            l = !1;
                            break;
                        default:
                            l = !0
                    }
                    l ? o.customConfirmDialog("提示", c, "保存并离开", "确定", "取消").then(function(n) {
                        if (n == "ok") {
                            var t = {};
                            t = i.patientId ? { patientId: i.patientId, menuId: i.menuId, toParams: u } : { url: i.name, toParams: u };
                            s.publish(s.events.EMRLeave, t);
                            return
                        }
                        n == "确定" && (e._hasConfirmed = !0, h.resolve(!0))
                    }) : o.confirm("提示", c).then(function() {
                        e._hasConfirmed = !0;
                        h.resolve(!0)
                    })
                }
            else h.resolve(!0);
            return h.promise
        },
        b = function(n) {
            f.loadTab(n.patientId).then(function(t) {
                var i, r, u;
                f.activateTab(t.id);
                i = null;
                i = c(n.action) ? t.activateMenu(n.action) : t.getActiveMenu();
                r = i.routeUrl;
                u = n.navParam;
                h(r, u)
            })
        },
        k = function(n, t) {
            this.lastState = n;
            t && f.backupTab()
        };
    return { navigate: b, navigateToUrl: h, navigateToPatient: l, navigateToMenu: w, getActiveMenu: p, confirmLeave: v, setLastState: k, PatientNavEventData: y }
}]);
frameworkModule.factory("patientTabManager", ["$log", "$timeout", "$q", "sessionCache", "dataDicSvc", "loginContext", "eventAggregator", "patientSvc", "officeOptionSvc", "permissionProvider", "userOptionSvc", "moduleOptionProvider", function(n, t, i, r, u, f, e, o, s, h, c, l) {
    "use strict";
    var y = r.getCache(r.keys.PatientTabState),
        v = function(n, t, i, r, u, f, e, o) {
            console.log(t);
            this.patientTab = n;
            this.id = t;
            this.name = i;
            this.module = r;
            this.className = u;
            this.permissionCode = f !== undefined && f != "" ? f : t;
            this.url = e;
            this.isDefault = o || !1;
            this.patientTab && this.setRouteUrl()
        },
        w, b;
    v.prototype = {
        setRouteUrl: function() {
            var n = "/patient/" + this.module;
            n += "/" + this.patientTab.patient.id;
            this.url != "" && (n += "/" + (this.url || this.id));
            this.routeUrl = n
        }
    };
    var a = [],
        g = function() { var n = i.defer(); return s.getOfficeOption(s.optionKeys.IsShangbaoEnabled).then(function(t) { n.resolve(t) }), n.promise },
        k = function() {
            var n = i.defer(),
                t, r;
            return f.isAdminOffice ? s.getOfficeOption(s.optionKeys.IsShangbaoEnabled).then(function(t) {
                a.push(new v(null, "adminRecord", "患者信息", "info", "icon-user", "patientMgmt.browse", null, !0));
                // t && a.push(new v(null, "health-insurance", "保险单", "info", "icon-calendar", "patientMgmt.heathInsurance"));
                a.push(new v(null, "apptRecord", "就诊记录", "info", "icon-calendar", "patientMgmt.apptRecord"));
                a.push(new v(null, "consultRecord", "咨询记录", "info", "icon-calendar", "patientMgmt.consultRecord"));
                n.resolve()
            }) : (t = s.getOfficeOption(s.optionKeys.IsShangbaoEnabled), r = h.loadPermissions(), i.all([t, r]).then(function(t) {
                a.push(new v(null, "record", "患者信息", "info", "icon-user", "patientMgmt.browse", null, !0));
                // t && t.length > 0 && t[0] && a.push(new v(null, "health-insurance", "保险单", "info", "icon-calendar", "patientMgmt.heathInsurance"));
                a.push(new v(null, "apptRecord", "就诊记录", "info", "icon-calendar", "patientMgmt.apptRecord"));
                a.push(new v(null, "testData", "患者检查数据", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "PatientHealth", "基本检查", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "CardiovascularStatus", "血液检查", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "StateOfTheKidney", "神经肾脏检查", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "DiabeticState", "尿检", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "EyesightCondition", "眼部检查", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "FootCare", "足部检查", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "membership", "会员信息", "info", "icon-user-follow", "patientMembership.browse"));
                // a.push(new v(null, "patientCharge", "收费", "charge", "glyphicon glyphicon-yen", "patientCharge.history", "order-records"));
                h.isAllowed("patientMedicalRecord.list") ? a.push(new v(null, "patientgeneralMedicalRecords", "电子病历", "patientgeneralMedicalRecords", "icon-film", "patientMedicalRecord.list", "emr/list")) : h.isAllowed("generalExam.history") ? a.push(new v(null, "patientgeneralMedicalRecords", "电子病历", "patientgeneralMedicalRecords", "icon-film", "generalExam.history", "general-exam/hint")) : h.isAllowed("perioExam.history") ? a.push(new v(null, "patientgeneralMedicalRecords", "电子病历", "patientgeneralMedicalRecords", "icon-film", "perioExam.history", "perio-exam/history")) : h.isAllowed("patientMgmt.txplan") && a.push(new v(null, "patientgeneralMedicalRecords", "电子病历", "patientgeneralMedicalRecords", "icon-film", "patientMgmt.txplan", "txplan/list"));
                // a.push(new v(null, "orthdontic", "正畸", "orthodontic", null, "patientMgmt.orthdontic", ""));
                // a.push(new v(null, "imagingHistory", "影像", "imaging", "icon-camera", "patientImaging.list"));
                // a.push(new v(null, "patientDocumentHistory", "文档", "patientdoc", "icon-docs", "patientDocument.list"));
                // a.push(new v(null, "diagnoseRecord", "处置记录", "info", "icon-calendar", "patientMgmt.diagnoseRecord"));
                a.push(new v(null, "followupHistory", "随访", "followup", "icon-call-end", "patientFollowup.history", "historyRecords"));
                // l.isNewDentalLabEnabled() ? a.push(new v(null, "patientDentalLab", "技加工", "patientDentalLab", "icon-printer", "dentalLab.order", "order")) : a.push(new v(null, "outprocessHistory", "技加工", "outprocess", "icon-printer", "patientOutProcess.history", "historyRecords"));
                a.push(new v(null, "prescriptionHistory", "处方", "prescription", "icon-plus", "patientPrescription.history", "historyRecords"));
                a.push(new v(null, "lisorder", "检验", "lisorder", "icon-heart", "patientLisOrder.history", "historyRecords"));
                a.push(new v(null, "revisit-record", "回访记录", "info", "icon-calendar", "patientMgmt.revisitRecord"));
                f.isGroup ? a.push(new v(null, "group-consult-record", "咨询记录", "info", "icon-calendar", "patientMgmt.consultRecord")) : a.push(new v(null, "consultRecord", "咨询记录", "info", "icon-calendar", "patientMgmt.consultRecord"));
                l.isCssdEnabled() && a.push(new v(null, "instrument-package-use-record", "器械包记录", "info", "icon-calendar", "patientMgmt.browse", "instrument-package-use-record"));
                // a.push(new v(null, "medical-exam-patient", "检查", "ehr", "icon-calendar", "medicalExam.apply"));
                n.resolve()
            })), n.promise
        },
        d = function() {
            var n = i.defer();
            return c.getUserOption(c.userOptionKey.userPatientMenus).then(function(t) {
                if (t) {
                    var i = JSON.parse(t);
                    angular.forEach(a, function(n) {
                        var t, r;
                        i = _.sortBy(i, "index");
                        t = _.findIndex(i, function(t) { return t.name == n.name });
                        t > -1 ? (r = i[t], _.extend(n, r), n.index = t) : n.isVisable = !0
                    })
                } else angular.forEach(a, function(n, t) {
                    n.isVisable = !0;
                    n.index = t
                });
                s.loadOfficeModuleOption().then(function(t) {
                    t && (!f.isGroup, t.enableOrthdonticModule == !1 && (a = _.filter(a, function(n) { return n.id != "orthdontic" })), t.isNewMedicalExamEnabled == !1 && (a = _.filter(a, function(n) { return n.id != "medical-exam-patient" })));
                    a = _.sortBy(a, "index");
                    n.resolve(a)
                })
            }), n.promise
        },
        p = function(n) {
            this.patient = n;
            this.id = n.id;
            this.tabName = n.name;
            this.menus = [];
            this.showUserMenus = [];
            this.hideUserMenus = [];
            angular.forEach(a, function(n) {
                if (h.isAllowed(n.permissionCode)) {
                    var t = _.clone(n);
                    t.patientTab = this;
                    t.setRouteUrl();
                    this.menus.push(t)
                }
            }, this)
        };
    return p.prototype = {
        refreshPatient: function(n) {
            this.tabName = n.name;
            _.extend(this.patient, n)
        },
        activateMenu: function(n) {
            var t = null,
                u, i;
            if (angular.forEach(this.menus, function(i) {
                    i.active = i.id == n;
                    i.active && (t = i)
                }), u = _.find(this.showUserMenus, function(t) { return t.id == n }), t.isShow = u ? !0 : !1, !t.isShow && (i = this.showUserMenus.length, i > 0)) {
                var f = _.clone(t),
                    e = _.clone(this.showUserMenus[i - 1]),
                    o = e.index,
                    r = _.findIndex(this.hideUserMenus, function(n) { return n.id == t.id });
                this.hideUserMenus[r] = e;
                this.hideUserMenus[r].isShow = !1;
                this.hideUserMenus[r].index = f.index;
                this.showUserMenus[i - 1] = f;
                this.showUserMenus[i - 1].isShow = !0;
                this.showUserMenus[i - 1].index = o;
                t.isShow = !0;
                t.index = o
            }
            return t
        },
        getActiveMenu: function() { var n = _.find(this.menus, { active: !0 }); return n || (n = _.find(this.menus, { isDefault: !0 }), n.active = !0), n },
        getData: function() {
            var t = this.getActiveMenu(),
                n = { patientId: this.patient.id, activeMenuId: t.id };
            return n.active = this.active || !1, n
        }
    }, w = function() {
        this.tabs = [];
        this.activeTab = null;
        this.isInitialized = !1;
        this.patientMenuDic = a
    }, b = function(n) {
        _.every(n.menus, function(n) { return !n.isVisable }) && _.each(n.menus, function(n) {
            var t = _.find(a, function(t) { return t.id === n.id });
            t && (n.isVisable = t.isVisable)
        })
    }, w.prototype = {
        add: function(n) {
            var t = _.find(this.tabs, function(t) { return t.id === n.id });
            t || this.tabs.push(n)
        },
        insert: function(n, t) { this.tabs.splice(n, 0, t) },
        remove: function(n) {
            this.tabs.splice(n, 1);
            this.tabs.length == 0 && (this.activeTab = null, y.clear())
        },
        removeAll: function(n) {
            this.tabs.splice(n, this.tabs.length);
            this.activeTab = null;
            y.clear()
        },
        loadTab: function(n) {
            _.isNumber(n) || (n = parseInt(n));
            var r = i.defer(),
                u = this,
                t = this.findTab(n);
            return t ? r.resolve(t) : o.getPatientsHeadInfo([n]).success(function(n) {
                var i = n[0];
                i && (t = new p(i), u.add(t), r.resolve(t))
            }), r.promise
        },
        isEmpty: function() { return this.isInitialized && this.tabs.length == 0 },
        findTab: function(n) { return _.find(this.tabs, { id: n }) },
        activateTab: function(n) {
            var t = null;
            return angular.forEach(this.tabs, function(i) {
                i.active = i.id === n;
                i.active && (t = i)
            }), this.activeTab = t, this.activeTab
        },
        getActiveTab: function() { return _.find(this.tabs, { active: !0 }) },
        resetActiveState: function() {
            this.activateTab(null);
            this.backupTab()
        },
        refreshTab: function(n) {
            var i = this.findTab(n.id),
                t;
            i && i.refreshPatient(n);
            angular.forEach(this.tabs, function(i) { i.patient.shareName == n.name && (t = i.patient, t.extension && n.extension && (t.extension.isSharedMembershipExpired = n.extension.isMembershipExpired)) });
            t && this.refreshTab(t)
        },
        closeTab: function(n) {
            var t = _.findIndex(this.tabs, { id: n });
            t >= 0 && this.remove(t)
        },
        backupTab: function() {
            var n = [];
            angular.forEach(this.tabs, function(t) {
                var i = t.getData();
                n.push(i)
            });
            y.saveObject(n)
        },
        initialize: function() {
            var n = this;
            k().then(function() { d().then(function() { n.initTab().then(function() { e.publish(e.events.PatientTabManagerInitialized) }) }) })
        },
        initTab: function() {
            var r = i.defer(),
                n = this,
                t = y.loadObject(),
                u;
            return t && t.length > 0 ? (u = _.pluck(t, "patientId"), o.getPatientsHeadInfo(u).success(function(i) {
                angular.forEach(t, function(t) {
                    var u = _.find(i, { id: t.patientId }),
                        r, f;
                    u && (r = _.find(n.tabs, function(n) { return n.id === u.id }), r ? b(r) : (r = new p(u), n.add(r)), r.active = t.active, r.active && (n.activeTab = r, f = n.findMenuByWindowLocation(), f && (t.activeMenuId = f.id)), _.each(r.menus, function(n) { n.active = t.activeMenuId === n.id }))
                });
                n.isInitialized = !0;
                r.resolve()
            })) : (n.isInitialized = !0, r.resolve()), r.promise
        },
        refreshPatientMenu: function(n) {
            angular.forEach(this.tabs, function(t) {
                angular.forEach(t.menus, function(t) {
                    var i = _.find(n, function(n) { return n.name == t.name });
                    i && (t.index = i.index, t.isVisable = i.isVisable)
                });
                t.menus = _.sortBy(t.menus, "index")
            })
        },
        findMenuByWindowLocation: function() {
            var r = window.location.hash,
                n = r.match(/patient\/(.*)\/\d+\/(.*)/),
                t, i;
            return n && n.length >= 2 ? (t = n[1], i = _.find(a, function(n) { var i = n.url || n.id; return n.module === t }), i) : null
        }
    }, new w
}]);
app.factory("hebeAppNavPortal", ["$q", "hebePortal", "appNav", function(n, t, i) {
    var r = function() { t.register("ares.appNav.goToYibaoCharge", function(n) { n && i.goToYibaoCharge(n.patientId, n.chargeOrderId, n.isYibaoOfGateway) }) },
        u = function() { t.register("ares.appNav.goToCharge", function(n) { n && i.goToCharge(n.patientId) }) },
        f = function() { t.register("ares.appNav.switchState", function(n) { n && i.switchState(n.stateName, n.stateParam, n.options) }) },
        e = function() {
            r();
            u();
            f()
        };
    return { init: e }
}]);
app.factory("hebeBusinessPortal", ["hebePortal", "moduleUtil", "$injector", "aresModalShelf", "$q", "patientUtil", "followupUtil", "enums", "shortMessageUtil", "loginContext", "practiceSvc", "$modal", "apptUtil", "aresYibaoLocalUtil", "multiOfficeDataDic", "reportv2Util", "$rootScope", "aresSlidePanel", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) {
    var d = function(t, i) { var f, e, o, s; return $("#hebe-container:visible").length !== 1 || window.openCheckInModalInstance ? (window.openCheckInModalInstance = undefined, f = r.open({ template: "<ares3-patient-check-in-modal-view><\/ares3-patient-check-in-modal-view>", controller: "Ares3PatientCheckInModalCtrl", title: "挂号", resolve: { host: function() { return { patientId: t, appt: i } } }, backdrop: !1, confirmClose: !0 })) : (e = (new Date).getTime() + "01", n.post("hebe.business.checkInModal", { patientId: t, appt: i }, e), o = u.defer(), f = { result: o.promise }, s = function() { n.registerOnce("ares.hebeModal.close", function(n, t) { if (e !== t) { s(); return } o.resolve(n) }) }, s()), f },
        g = function(n) { return r.open({ template: "<ares3-provider-certificate-edit-modal-view><\/ares3-provider-certificate-edit-modal-view>", controller: "Ares3ProviderCertificateEditModalCtrl", title: "上传医生证件信息", resolve: { host: function() { return { providerId: n } } }, backdrop: !1 }) },
        nt = function(t) {
            var u = t.id ? "修改预约" : "新建预约",
                i = t.id ? "edit" : "new";
            if (angular.element("#hebe-container:visible").length > 0) { n.post("hebe.business.appointmentEditModal", { appt: t, action: i }); return }
            return r.open({ template: "<ares3-patient-appointment-edit-modal-view><\/ares3-patient-appointment-edit-modal-view>", controller: "Ares3PatientAppointmentEditModalCtrl", title: u, resolve: { host: function() { return { appt: t, action: i } } }, backdrop: !1, confirmClose: !0 })
        },
        tt = function(r, u) {
            var f = r.checkInInfo;
            t.load("charge").then(function() { var n = i.get("chargeBaseDialogUtil"); return n.editCheckInOrderView(f.patientId, f.apptId, f) }).then(function(t) { n.post("hebe.business.checkInChargeResult", { data: t }, u) })
        },
        it = function(t, i) {
            var r = t.patient,
                u = t.action;
            f.changePatientType(t.patient, t.action).then(function() { n.post("hebe.business.changePatientTypeResult", null, i) })
        },
        rt = function(r, u) { t.load("charge").then(function() { var n = i.get("chargeRecordsOrderUtil"); return n.showChargeConfirm(r.chargeOrder, r.allowAliPay) }).then(function(t) { n.post("hebe.business.showChargeConfirmResult", t, u) }) },
        ut = function(r, u) { t.load("charge").then(function() { var n = i.get("chargeRecordsOrderUtil"); return n.showNewChargeConfirm(r.chargeOrder, r.chargeOrderList, r.allowAliPay) }).then(function(t) { n.post("hebe.business.showNewChargeConfirmResult", t, u) }) },
        ft = function(r, u) { t.load("charge").then(function() { var n = i.get("chargeRecordsOrderUtil"); return n.showChargeRefund(r.chargeOrder) }).then(function(t) { n.post("hebe.business.showChargeRefundResult", t, u) }) },
        et = function(t, i) {
            var r = l.open({ template: "<patient-source-type-edit-view><\/patient-source-type-edit-view>", controller: "PatientSourceTypeEditCtrl", windowClass: "yibao-gateway-settlement", title: "患者来源管理", resolve: { host: function() { return {} } }, backdrop: !1 });
            r.result.then(() => { n.post("hebe.business.editPatientSourceType", !0, i) })
        },
        ot = function(r, u) { t.load("charge").then(function() { var n = i.get("chargeRecordsOrderUtil"); return n.drawGiftCertificate(r.chargeOrder) }).then(function(t) { n.post("hebe.business.drawGiftCertificateResult", t, u) }) },
        st = function(t, i) { s.sendMessage(t.patientId, t.apptId, function(t) { n.post("hebe.business.smsResult", { data: t }, i) }) },
        ht = function(t, i) {
            var r = { creatorId: h.userId, followupRule: { ruleType: o.FollowupRuleType.ManualRule, creationMode: o.FollowupCreationMode.AllAtOnce, timeMode: o.FollowupTimeMode.Absolute } },
                u = e.openBatchCreateFollowupDialog(r, t.selectedAppts);
            u.then(function() { n.post("hebe.business.batchCreateFollowUpResult", { result: !0 }, i) })
        },
        ct = function() {
            c.getSpeechCallSearchConfigs().success(function(n) {
                if (n && n.length !== 0) {
                    var t = l.open({ animation: !0, backdrop: "static", template: "<speech-call-select-view><\/speech-call-select-view>", controller: "SpeechCallSelectCtrl", size: "md", resolve: { host: function() { return { configs: n } } } });
                    t.result.then(function(n) { n && k(n) })
                } else k()
            })
        },
        k = function(n) {
            var t = [],
                i, r;
            n && n.department && t.push("department=" + n.department);
            n && n.operatory && t.push("operatory=" + n.operatory);
            n && n.speechName && t.push("speechName=" + n.speechName);
            i = t.join("&");
            r = "/speechcallpatient?" + i;
            window.open(r, "_blank")
        },
        lt = function(t, i) {
            f.openPatientMatchDialog(t.parseApplyPatient).then(function(t) {
                _.isObject(t) && _.isObject(t.bindingPatient) && (delete t.bindingPatient._events, delete t.bindingPatient._handlers, delete t.bindingPatient.parent);
                n.post("hebe.business.patientMatchDialogResult", t, i)
            })
        },
        at = function(t, i) { f.createPatient(t.allowCreateAppt, t.patient).then(function() { n.post("hebe.business.createPatientResult", null, i) }) },
        vt = function(r, u) { t.load("charge").then(function() { var n = i.get("chargeBaseDialogUtil"); return n.editApptApplyComplateOrderView(r.appt.patientId, r.appt.id, r.imageCancelNote) }).then(function() { n.post("hebe.business.editApptApplyComplateOrderViewResult", null, u) }) },
        yt = function(t, i) { a.checkWeInsuranceComplateImageDialog(t.apptId, t.images, t.notes).then(function(t) { n.post("hebe.business.openCheckWeInsuranceComplateImageDialog", t, i) }) },
        pt = function(t, i) {
            var r = t.appt,
                u = t.images && t.images.length > 0 ? t.images : null,
                f = t.apptApply;
            a.showWeSureServiceDialog(r.id, u, f.notes).then(function(t) { n.post("hebe.business.showWeSureServiceDialogResult", t.data, i) })
        },
        wt = function(t, i) { a.showContactHistoryDialog(t.apptApply, t.targetType, t.targetId).then(function(t) { n.post("hebe.business.showContactHistoryDialogResult", t, i) }) },
        bt = function(t, i) {
            var r = t.patientId;
            f.openWechatBindingDialog(r).then(function(t) { n.post("hebe.business.openWechatBindingDialogResult", t, i) })
        },
        kt = function(t, i) {
            let u = "--";
            switch (t.type) {
                case o.InventoryOrderType.InOrder:
                    u = "入库单";
                    break;
                case o.InventoryOrderType.OutOrder:
                    u = "出库单";
                    break;
                case o.InventoryOrderType.TransferOrder:
                    u = "调拨单";
                    break;
                case o.InventoryOrderType.CheckInOrder:
                    u = "盘点单"
            }
            modalInstance = r.open({ template: "<inventory-pre-order-show-dialog-view><\/inventory-pre-order-show-dialog-view>", controller: "InventoryPreOrderShowDialogCtrl", title: u, resolve: { host: function() { return t } }, backdrop: !1 });
            modalInstance.result.then(function(t) { n.post("hebe.business.openSupplychainPreOrderDetailResult", t, i) })
        },
        dt = function(r, u) { t.load("tenant").then(function() { var t = i.get("tenantUtil"); return t.openAcceptanceReportDialog(r.officeInfo).then(function(t) { n.post("hebe.business.openViewAcceptanceReportDialogResult", t, u) }) }) },
        gt = function(r, u) { t.load("charge").then(function() { var t = i.get("chargeBaseDialogUtil"); return t.yibaoCheckInFeeBrowseView(r.sourceChargeOrder, r.yibaoOrder, r.yibaoReport, r.checkInInfo).then(function(t) { n.post("hebe.business.yibaoCheckInFeeBrowse", t, u) }) }) },
        ni = function(r, u) { t.load("charge").then(function() { var t = i.get("chargeBaseDialogUtil"); return t.yibaoEditCheckInRepayView(r.chargeOrder, r.yibaoOrder, r.confirmGetReport).then(function(t) { n.post("hebe.business.yibaoCheckInChargeResult", t, u) }) }) },
        ti = function(t, i) { return v.openReadCardView(t.isInitReadIc).then(function(t) { n.post("hebe.business.yibaoLocalReadCardAction", t, i) }) },
        ii = function(t, i) { return f.createPatient(t.allowCreateAppt, t.patient).then(function(t) { n.post("hebe.business.patientQuickEditModal", t, i) }) },
        ri = function(t, i) {
            var r = u.defer();
            t.selectedItems ? t.isFullMode ? r.resolve(t.selectedItems) : y.loadDic(t.officeId, "chargeItemDic").then(function(n) {
                var i = _.filter(n, function(n) { return _.contains(t.selectedItems, n.itemName) || _.contains(t.selectedItems, n.id) });
                r.resolve(i)
            }) : r.resolve(null);
            r.promise.then(function(r) {
                var u;
                u = t.isFullMode ? l.open({ animation: !0, backdrop: "static", template: "<charge-item-selector-plus-view><\/charge-item-selector-plus-view>", controller: "ChargeItemSelectorPlusCtrl", windowClass: "membership-discountplan-detail-dialog", resolve: { host: function() { return { existChargeItemList: r || [] } } } }) : l.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "chargeItem", officeId: t.officeId, list: r || [] } } } });
                u.result.then(function(t) { n.post("hebe.business.openChargeItemSelectDialogResult", t, i) })
            })
        },
        ui = function(i, r) {
            t.load("dashboard").then(function() {
                var t = i.dataItem.patientId || i.dataItem.id,
                    u = b.open("<customer-details-view><\/customer-details-view>", "CustomerDetailsCtrl", { host: function() { return { patientId: t, isHideBtn: !0 } } }, w, "confirm");
                u.result.then(function(t) { n.post("hebe.business.openPatientDetailModalResult", t, r) })
            })
        },
        fi = function(t, i) {
            var u = t.linkType == "model" ? l : r,
                f = u.open({ template: "<reportv2-dialog-view><\/reportv2-dialog-view>", controller: "Reportv2DialogCtrl", title: t.title, resolve: { dataHost: function() { return { resultColumn: t.resultColumn, dataItem: t.dataItem, title: t.title, mainCriteria: t.criteria } } }, needActive: !0 });
            f.result.then(function(t) { n.post("hebe.business.openReportDetailModalResult", t, i) })
        },
        ei = function() {
            n.register("ares.business.checkInCharge", tt);
            n.register("ares.business.changePatientType", it);
            n.register("ares.business.showChargeConfirm", rt);
            n.register("ares.business.showNewChargeConfirm", ut);
            n.register("ares.business.showChargeRefund", ft);
            n.register("ares.business.drawGiftCertificate", ot);
            n.register("ares.business.sms", st);
            n.register("ares.business.batchCreateFollowUp", ht);
            n.register("ares.business.speechCall", ct);
            n.register("ares.business.patientMatchDialog", lt);
            n.register("ares.business.createPatient", at);
            n.register("ares.business.editApptApplyComplateOrderView", vt);
            n.register("ares.business.showWeSureServiceDialog", pt);
            n.register("ares.business.showContactHistoryDialog", wt);
            n.register("ares.business.openWechatBindingDialog", bt);
            n.register("ares.business.openSupplychainPreOrderDetail", kt);
            n.register("ares.business.editPatientSourceType", et);
            n.register("ares.business.openViewAcceptanceReportDialog", dt);
            n.register("ares.business.openCheckWeInsuranceComplateImageDialog", yt);
            n.register("ares.business.yibaoCheckInFeeBrowse", gt);
            n.register("ares.business.yibaoCheckInChargeResult", ni);
            n.register("ares.business.yibaoLocalReadCardAction", ti);
            n.register("ares.business.patientQuickEditModal", ii);
            n.register("ares.business.openChargeItemSelectDialog", ri);
            n.register("ares.business.openPatientDetailModal", ui);
            n.register("ares.business.openReportDetailModal", fi)
        };
    return { init: ei, openCheckInModal: d, openDoctorCertificateModal: g, openAppointmentEditModal: nt }
}]);
app.factory("hebePortal", ["$rootScope", "$document", "$state", "userSvc", "ares3StateMapping", function(n, t, i, r, u) {
    var f = {},
        e = [],
        h = function(n, t) { angular.isFunction(t) && (f[n] = f[n] || [], f[n].indexOf(t) < 0 && f[n].push(t)) },
        c = function(n, t) { angular.isFunction(t) && (f[n] = f[n] || [], f[n].indexOf(t) < 0 && (f[n].push(t), e.push(t))) },
        l = function(n, t) {
            f[n] = f[n] || [];
            f[n] = _.filter(f[n], function(n) { return n !== t })
        },
        s = function(n, t, i) {
            _.each(f[n], function(r) {
                if (angular.isFunction(r)) {
                    r(t, i);
                    var u = e.indexOf(r);
                    u > -1 && (e.splice(u, 1), f[n] = _.filter(f[n], function(n) { return n !== r }))
                }
            })
        },
        a = function(n, i, r, u) {
            var e;
            if (!n.startsWith("hebe.")) { console.error("[HebePortal] message name " + n + ' should start with "hebe."'); return }
            var s = localStorage.getItem("isHebeDevMode") === "1",
                h = s ? "http://localhost:9636" : window.location.origin,
                c = u ? "#hebe-deputy-container" : "#hebe-container",
                f = t.find(c).find("iframe");
            f.length !== 0 && (e = f[0].contentWindow, i = angular.copy(i), o(i), e.postMessage({ name: n, data: i, uniqId: r }, h))
        },
        o = function(n) {
            Array.isArray(n) ? _.each(n, function(t, i) { typeof t == "function" ? n.splice(i, 1) : o(t) }) : typeof n == "object" && _.each(_.keys(n), function(t) {
                var i = n[t];
                typeof i == "function" ? delete n[t] : o(i)
            })
        };
    return function() {
        console.log("HebePortal alive.");
        window.addEventListener("message", function(t) {
            var f = t.data,
                e, c, o, h, l;
            switch (f.name) {
                case "ares.router.navigate":
                    e = f.data.target;
                    c = f.data.params;
                    e && (window.Ares3 && (e = u.translate(e) || e), i.go(e, c));
                    break;
                case "ares.router.redirectToUrl":
                    f.data.url && (window.location = f.data.url);
                    break;
                case "ares.router.syncRoute":
                    if (o = $("body").find("ares-new-home-view").offset(), o && (window.Ares3 && (o.top !== 58 || o.left !== 88) || !window.Ares3 && (o.top !== 55 || o.left !== 106))) return;
                    h = f.data.routeName;
                    h && (l = window.Ares3 ? "/ares3/#/new/" : "/#/new/", window.history.pushState({}, "", l + h), s(f.name, f.data), Ares.sensors.autotrackspa());
                    break;
                case "ares.token.invalidated":
                    r.checkIdentity();
                    break;
                case "ares.broadcast.startChat":
                    n.$broadcast("start-chat", f.data.openId);
                    break;
                default:
                    f.name && s(f.name, f.data, f.uniqId)
            }
        })
    }(), { register: h, registerOnce: c, unregister: l, post: a }
}]);
frameworkModule.directive("appSideBar", ["$log", "$timeout", "eventAggregator", "$rootScope", "officeUtil", "loginContext", "$stateParams", "hebePortal", function(n, t, i, r, u, f, e, o) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/app-side-bar.html",
        replace: !0,
        scope: {},
        controller: "AppSideBarController",
        link: function(n, s) {
            var h = function() {
                    var n;
                    $(".nav-sidebar > li").hover(function() {
                        clearTimeout(n);
                        $(this).siblings().removeClass("nav-hover");
                        $(this).addClass("nav-hover")
                    }, function() {
                        var t = $(this);
                        n = setTimeout(function() { t.removeClass("nav-hover") }, 200)
                    });
                    $(".nav-sidebar > li .children").hover(function() {
                        clearTimeout(n);
                        $(this).closest(".nav-parent").siblings().removeClass("nav-hover");
                        $(this).closest(".nav-parent").addClass("nav-hover")
                    }, function() {
                        var t = $(this);
                        n = setTimeout(function() { $(this).closest(".nav-parent").removeClass("nav-hover") }, 200)
                    });
                    createSideScroll()
                },
                l = function(i) { i.hasVisibleSubItem ? t(function() { refreshSideScroll() }, 200) : n.navigate(i) },
                a = function() { t(h, 200) },
                c = function() {
                    var t = localStorage.getItem("newInventoryHome_showGuide");
                    n.showInventoryNewBadge = t !== "never"
                },
                v = function() { f.isRootGroup || u.getGroupProcurementMethod().then(function(n) { n === "group" && s.find(".nav-sidebar-item-mallcenter").parent().remove() }) },
                y = function(n, t) { if (n.id === "new") { var i = e.route === n.param.route; return i && (t.isActive = !0), i } return n.isActive },
                p = function() { o.register("ares.router.syncRoute", function() { n.$apply() }) };
            (function() {
                c();
                p();
                n.refreshView = l;
                n.checkActive = y;
                r.isInitialized ? t(h, 200) : i.subscribe(n, "appInitialized", a);
                i.subscribe(n, "InventoryNewGuideHideForever", c);
                i.subscribe(n, "appInitialized", v)
            })()
        }
    }
}]);
frameworkModule.directive("appTopBar", ["$log", "$timeout", "$interval", "$document", "eventAggregator", "$rootScope", "$q", "loginToken", "permissionProvider", "messageCenterSvc", "userSvc", "appNav", "$modal", "userOptionSvc", "sessionCache", "$state", "loginContext", "patientUtil", "hebePortal", "aresNotification", "speechCallSvc", "officeOptionSvc", "practiceSvc", "cardReaderService", "membershipSvc", "systemConfigSvc", "customerServiceSvc", "apptApplyCompleteUtil", "tenantSvc", "enums", "aresDialog", "aresModalShelf", "dataDicSvc", "officeOptionUtil", "localSvc", "aresYibaoLocalUtil", "officeUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt, it, rt, ut, ft, et, ot, st, ht, ct, lt, at, vt, yt, pt) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/app-top-bar.html",
        replace: !0,
        controller: "AppSideBarController",
        link: function(n, e) {
            var rt = Ares.globalEventUtil(r),
                dt = !0,
                g = 0,
                o = { weChatBizMessageCode: "scheduleCenter.weixinApplyList", unChargeMessageCode: "dashBoard.uncharge", stockRemindMessageCode: "inventoryBrowse.stockStatus", shortMessageBackCode: "shortMessage.reply", shortMessageRemindCode: "shortMessage.charge", workflowReminderCode: "workflowManagement.approval", RemindTimeOutCode: "remindTimeOut", memoMessageCode: "memoManagement.record", strongRemind: "scheduleCenter.strongRemind", editMedicalRecordCode: "patientMedicalRecord.create" },
                gt = y.getCache(y.keys.MessageCenterIgnoredBizMessageCode),
                hi = function() {
                    var t = gt.loadObject();
                    t && _.extend(n.bizMessageCodes, t)
                },
                ni = function() {
                    var n;
                    $(".nav-sidebar > li").hover(function() {
                        clearTimeout(n);
                        $(this).siblings().removeClass("nav-hover");
                        $(this).addClass("nav-hover")
                    }, function() {
                        var t = $(this);
                        n = setTimeout(function() { t.removeClass("nav-hover") }, 200)
                    });
                    $(".nav-sidebar > li .children").hover(function() {
                        clearTimeout(n);
                        $(this).closest(".nav-parent").siblings().removeClass("nav-hover");
                        $(this).closest(".nav-parent").addClass("nav-hover")
                    }, function() {
                        var t = $(this);
                        n = setTimeout(function() { $(this).closest(".nav-parent").removeClass("nav-hover") }, 200)
                    });
                    createSideScroll()
                },
                p = function(n, t, i, r, u) { n.push({ menuName: t.title, menuClass: i, menuBigClass: r, state: u, createTimeText: t.createTimeText, createTimeFormatText: t.createTimeFormatText, count: t.count, isShow: !0, isShowDel: !1, content: t.content, messageItems: t.messageItems }) },
                ti = function(n) { var t = []; return n && $.each(n, function(n, i) { i.messageType == "系统公告" ? p(t, i, "系统公告", "系统公告", "") : i.messageType == "网络预约" ? p(t, i, "网络预约", "业务提醒", "dashBoard.appointApply") : i.messageType == "收费提醒" ? p(t, i, "收费提醒", "业务提醒", "dashBoard.uncharge") : i.messageType == "库存预警" ? p(t, i, "库存预警", "预警信息", "inventoryBrowse.stockStatus") : i.messageType == "短信预警" ? p(t, i, "短信预警", "预警信息", "shortMessage.charge") : i.messageType == "短信回复" ? p(t, i, "短信回复", "业务提醒", "shortMessage.feedback") : i.messageType == "审批提醒" ? p(t, i, "审批提醒", "业务提醒", "workflowManagement.approval") : i.messageType == "备忘提醒" ? p(t, i, "备忘提醒", "业务提醒", "memo.list") : i.messageType == "病历打回" && p(t, i, "病历打回", "业务提醒", "medicalrecordCenter.myEmr") }), t },
                ci = function(i) {
                    i.subItems || n.navigate(i);
                    t(function() { refreshSideScroll() }, 200)
                },
                li = function() {
                    n.isCustomizeOpen && n.extension && n.extension.helpLink ? window.open(n.extension.helpLink) : lt.helpPageDic.load().then(function(n) {
                        angular.forEach(n, function(n) {
                            n.saasPageUrl.lastIndexOf("/") == n.saasPageUrl.length - 1 && (n.saasPageUrl = n.saasPageUrl.substring(0, n.saasPageUrl.length - 1));
                            n.saasPageUrl.indexOf("#") != 0 && (n.saasPageUrl = "#/" + n.saasPageUrl)
                        });
                        var i = ai(),
                            t = ii(i, n);
                        ot.getHelpPageSso().then(function(n) {
                            var i = t;
                            n.data && (i = n.data + "&return_to=" + t);
                            window.open(i)
                        }, function() { window.open(t) })
                    });
                    kt("帮助")
                },
                ai = function() {
                    var n = window.location.hash,
                        t = n.indexOf("?");
                    return t > -1 && (n = n.substring(0, t)), n
                },
                ii = function(n, t) {
                    var i = "https://lccs.kf5.com",
                        u = _.find(t, { saasPageUrl: n }),
                        r;
                    return u ? i = u.helpPageUrl : (r = n.lastIndexOf("/"), r > -1 && (n = n.substring(0, r), i = ii(n, t))), i
                },
                vi = function(n) { n.isShow = !1 },
                yi = function(t) {
                    if (t.isShow = t.count > 0, t.menuBigClass == "系统公告") {
                        t.count = t.count - 1;
                        var i = _.filter(t.messageItems, { hasRead: !1 });
                        i && (n.readMessage(i[i.length - 1].id), wt())
                    } else {
                        t.count = 0;
                        switch (t.menuClass) {
                            case "网络预约":
                            case "收费提醒":
                                w.dashboardType == "FrontDesk" ? l.switchState(t.state, { status: t.state }) : l.goToState("apptMgmt.weixinApplyList");
                                break;
                            case "库存预警":
                                s.isAllowed(o.stockRemindMessageCode) && l.goToState("supplychain.inventory.stockRemind");
                                break;
                            case "备忘提醒":
                            case "短信预警":
                            case "病历打回":
                                l.goToState(t.state);
                                break;
                            case "短信回复":
                                h.updateBizMessageLog(1);
                                l.goToState(t.state);
                                break;
                            case "审批提醒":
                                h.updateBizMessageLog(6).then(function() {
                                    var n = [];
                                    n.push(o.workflowReminderCode);
                                    di(n)
                                });
                                l.goToState(t.state)
                        }
                    }
                },
                pi = function(n, t) {
                    Ares.sensors.track("webclick", { OperationType: "查看网络预约任务", EventType: "网络预约操作" });
                    var i = "";
                    i = _.isUndefined(t) || _.isNull(t) ? "查看更多" : t ? "核销提醒" : "预约提醒";
                    Ares.sensors.track("NewAppointmentApply", { OperationType: "网络预约任务列表点击", OperationMode: i });
                    l.goToDashBoardApply("", n)
                },
                wi = function(t) {
                    var i = _.find(n.messageData, { menuClass: t });
                    i.isShow = !1
                },
                bi = function() {
                    v.checkMsgNotTroubleMode().then(function(t) { n.notTrouble = n.isMessageNotDisturbDisalbed ? !1 : t });
                    n.$on("to-parent-notTrouble", function(t, i) { n.notTrouble = i });
                    n.$on("to-parent-messages", function(t, i) {
                        tt(n.messageData, i, "系统公告");
                        tt(n.messageData, i, "网络预约");
                        tt(n.messageData, i, "收费提醒");
                        tt(n.messageData, i, "审批提醒");
                        tt(n.messageData, i, "备忘提醒");
                        tt(n.messageData, i, "病历打回");
                        n.messageData = i
                    });
                    wt();
                    h.getTimerSeconds().success(function(n) {
                        var t = 600,
                            r;
                        n = n && n > t ? n : t;
                        r = i(function() { wt() }, n * 1e3)
                    })
                },
                tt = function(n, t, i) {
                    var u = _.find(n, { menuClass: i }),
                        r = _.find(t, { menuClass: i });
                    r && u && !r.isChangeShow && (r.isShow = u.isShow)
                },
                k = function(t, i, r, u) {
                    var f = _.filter(i, { messageType: r }),
                        o = _.filter(n.bizMessageCodes, { code: u }),
                        e;
                    f.length > 0 && (o.length > 0 && o[0].time < f[0].createTimeText || o.length == 0) && (t || (t = []), e = _.find(t, { menuClass: r }), e ? (e.createTimeText = f[0].createTimeText, e.createTimeFormatText = f[0].createTimeFormatText, e.count = f[0].count, e.content = f[0].content, e.messageItems = f[0].messageItems) : t.push(f[0]))
                },
                ki = function(n) {
                    _.each(n, function(n) {
                        var t = new Date(n.createTime);
                        n.isOver30m = (Ares.today() - t) / 6e4 > 30 ? !0 : !1
                    })
                },
                ri = function(t, i, r, u, f) {
                    var e = _.filter(i, { messageType: r }),
                        o = _.filter(n.bizMessageCodes, { code: u }),
                        s = _.filter(n.bizMessageCodes, { code: f });
                    e.length > 0 && s.length == 0 && (o.length > 0 && o[0].time < e[0].createTimeText || o.length == 0) && (t || (t = []), t.push(e[0]))
                },
                wt = function() {
                    s.loadPermissions().then(function() {
                        hi();
                        var n = [];
                        (s.isAllowed(o.weChatBizMessageCode) || w.dashboardType) && n.push(o.weChatBizMessageCode);
                        s.isAllowed(o.shortMessageBackCode) && n.push(o.shortMessageBackCode);
                        s.isAllowed(o.shortMessageRemindCode) && n.push(o.shortMessageRemindCode);
                        w.dashboardType == "FrontDesk" ? (n.push(o.unChargeMessageCode), n.push(o.stockRemindMessageCode), s.isAllowed(o.strongRemind) && n.push(o.strongRemind)) : s.isAllowed(o.stockRemindMessageCode) && n.push(o.stockRemindMessageCode);
                        s.isAllowed(o.memoMessageCode) && n.push(o.memoMessageCode);
                        s.isAllowed(o.editMedicalRecordCode) && n.push(o.editMedicalRecordCode);
                        n.push(o.workflowReminderCode);
                        gi(n)
                    })
                },
                di = function(t) {
                    h.getMessages(t).success(function(t) {
                        k(n.messageData, t, "审批提醒", o.workflowReminderCode);
                        wi("审批提醒");
                        n.$broadcast("to-child-messages-count", fi())
                    })
                },
                gi = function(i) {
                    h.getMessages(i).success(function(i) {
                        var r = _.filter(i, { messageType: "系统公告" });
                        n.apptApplysRemind = _.find(i, function(n) { return n.messageType === "预约强提醒" });
                        n.apptApplysRemind && n.apptApplysRemind.messageItems && (n.checkoutRemind = _.filter(n.apptApplysRemind.messageItems, function(n) { return n.title === "核销" }), n.applyRemind = _.filter(n.apptApplysRemind.messageItems, function(n) { return n.title === "预约" }), n.isShowMoreMessage = n.checkoutRemind && n.checkoutRemind.length > 1 || n.applyRemind && n.applyRemind.length > 3, n.checkoutRemind && n.checkoutRemind.length > 1 && (n.checkoutRemind = n.checkoutRemind.slice(0, 1)), n.applyRemind && n.applyRemind.length > 3 && (n.applyRemind = n.applyRemind.slice(0, 3)), ki(n.applyRemind), s.isAllowed("scheduleCenter.strongRemind") && !n.isStrongMessageDisabled && (et.isIncludeTypes(n.enabledApptChannel) || n.enabledApptChannel.includes("wesure")) && (n.checkoutRemind && n.checkoutRemind.length > 0 || n.applyRemind && n.applyRemind.length > 0) && (n.isShowStrongMessage = !0));
                        k(r, i, "网络预约", o.weChatBizMessageCode);
                        k(r, i, "收费提醒", o.unChargeMessageCode);
                        ri(r, i, "库存预警", o.shortMessageRemindCode, o.RemindTimeOutCode);
                        ri(r, i, "短信预警", o.shortMessageRemindCode, o.RemindTimeOutCode);
                        k(r, i, "短信回复", o.shortMessageBackCode);
                        k(r, i, "审批提醒", o.workflowReminderCode);
                        k(r, i, "备忘提醒", o.memoMessageCode);
                        k(r, i, "病历打回", o.editMedicalRecordCode);
                        n.messageData = ti(r);
                        dt ? (t(function() {
                            $.each(n.messageData, function(n, t) {
                                if (t.menuClass == "系统公告") {
                                    var i = _.filter(t.messageItems, { hasRead: !1 });
                                    g += i.length
                                } else g += t.count
                            })
                        }, 1e3), dt = !1) : n.$broadcast("to-child-messages-count", fi());
                        h.getHideTimeOutSeconds().success(function(i) {
                            t(function() {
                                $.each(n.messageData, function(t, i) {
                                    var r;
                                    r = i ? i.createTimeText : toLongDateTimeString(new Date);
                                    (i.menuClass == "库存预警" || i.menuClass == "短信预警") && (i.isShow = !1, n.bizMessageCodes.push({ code: o.RemindTimeOutCode, time: r }), hr(n.bizMessageCodes))
                                })
                            }, i * 1e3)
                        })
                    })
                },
                nr = function(t) { var i = _.reject(n.messageData, { id: t }) },
                tr = function() { t(ni, 200) },
                ir = function() { window.open("/Scrm") },
                rr = function(t) { c.readMessage(t).success(function(t) { wt(); var i = a.open({ animation: !0, backdrop: "static", template: "<message-detail-view><\/message-detail-view>", controller: "MessageDetailCtrl", windowClass: "message-detail-dialog", size: "lg", resolve: { host: function() { return g && (g = g - 1, n.$broadcast("to-child-messages-count", g)), { message: t } } } }) }) },
                ui = function(n) { var t = _.filter(n.messageItems, { hasRead: !1 }); return n.menuBigClass == "系统公告" ? t.length : n.count },
                fi = function() {
                    var i = 0,
                        t = 0;
                    return n.messageData && $.each(n.messageData, function(n, r) {
                        if (i += r.count, r.menuClass == "系统公告") {
                            var u = _.filter(r.messageItems, { hasRead: !1 });
                            t += u.length
                        } else t += r.count
                    }), t
                },
                vu = function() {
                    var t = [];
                    s.isAllowed(o.weChatBizMessageCode) ? t.push(o.weChatBizMessageCode) : w.dashboardType && t.push(o.weChatBizMessageCode);
                    h.getMessages(t).success(function(t) { n.messageData = ti(t) })
                },
                ei = function() {
                    n.isPointBoardOpened = !0;
                    rt.onMousedown(ur);
                    rt.onMouseenter(fr);
                    Ares.sensors.track("AppSideBarOperation", { OperationType: "积分" })
                },
                ur = function(t) {
                    var i = $(t.target).parents(".popover").length;
                    i || n.$apply(function() { bt() })
                },
                fr = function(t) {
                    var i = $(t.target).parents(".popover").length;
                    i ? ei(t) : n.$apply(function() { bt() })
                },
                bt = function() {
                    n.isPointBoardOpened = !1;
                    rt.offMousedown()
                },
                er = function(n) { $(n.toElement).hasClass("popover") || bt() },
                or = function() { w.isAdminOffice ? b.createAdminPatient(!0).then(function(n) { l.goToPatient(n.id) }) : b.createPatient(!0).then(function(n) { if (w.isGroup) { var t = b.getPatientPermissionLevel(); if (t == st.PatientPermissionLevel.Personal && (!n.extension && w.providerId || w.providerId != n.extension.onlineConsultantId)) { ht.info("提示", "无患者数据访问权限！"); return } } l.goToPatient(n.id) }) },
                sr = function() { yt.readCard() },
                hr = function(n) { gt.saveObject(n) },
                cr = function() { bi() },
                lr = function() { nt.getOfficeOption(nt.optionKeys.IsFaceRecognitionEnabled).then(function(t) { n.isFaceRecognitionEnabled = t }) },
                ar = function() {
                    n.isEnableICCard = 1;
                    nt.getOfficeOption(nt.optionKeys.IsEnableICCard).then(function(t) { n.isEnableICCard = t })
                },
                vr = function() { nt.getOfficeOptions([nt.optionKeys.IsMessageNotDisturbDisalbed, nt.optionKeys.IsMessageClearAllDisalbed, nt.optionKeys.MessagePostponeConfig, nt.optionKeys.IsStrongMessageDisabled, nt.optionKeys.EnabledApptChannel]).then(function(t) { _.isArray(t) ? (n.isMessageNotDisturbDisalbed = !!t[0], n.isMessageClearAllDisalbed = !!t[1], n.isApptApplyDisabled = t[2] ? !!t[2].IsApptApplyDisabled : !1, n.isStrongMessageDisabled = !!t[3], n.enabledApptChannel = t[4]) : (n.isMessageNotDisturbDisalbed = !1, n.isMessageClearAllDisalbed = !1, n.isApptApplyDisabled = !1, n.isStrongMessageDisabled = !1, n.enabledApptChannel = "") }) },
                yr = function() {
                    n.isYibaoReadCardEnabled = !1;
                    return nt.getOfficeOption(nt.optionKeys.IsYibaoGatewayEnabled).then(function(t) {
                        (n.isYibaoGatewayEnabled = t, t) && (lt.insuranceMateDataDic || lt.initialize(), lt.insuranceMateDataDic.load().then(function(t) { t && t.length != 0 && (n.yibaoChannelDict = t.map(function(n) { return { name: n.displayName, value: n.name, canReadCard: n.canReadCard } }), n.yibaoChannelDict.length >= 1 && (n.yibaoUseChannel = n.yibaoChannelDict[0].value, n.yibaoUseChannelCache = y.getCache(y.keys.YibaoUseChannel), n.yibaoUseChannelCache.saveValue(n.yibaoUseChannel), n.yibaoChannelDict[0].canReadCard === !0 && (n.isYibaoReadCardEnabled = !0))) }))
                    })
                },
                pr = function(t) {
                    n.yibaoUseChannel = t;
                    n.yibaoUseChannelCache.saveValue(n.yibaoUseChannel);
                    n.isYibaoReadCardEnabled = n.yibaoChannelDict.find(n => n.value === t).canReadCard ? !0 : !1
                },
                wr = function() {
                    it.read().then(function(n) {
                        var t = n.data,
                            r, i;
                        t && t.issuccess && t.cardno ? (r = t.cardno, i = e.find("#search-input-box"), i.val(r), i.click()) : d.error("读卡失败，请检查卡片是否正确插入或重试")
                    }).catch(function() { d.error("读卡失败，请检查本地服务是否正常运行") })
                },
                br = function() {
                    var n = w.userId;
                    ft.update(n);
                    qimoChatClick();
                    kt("客服")
                },
                kr = function() {
                    ot.GetTenantIsCustomizeOpen().then(function(t) {
                        n.isCustomizeOpen = t.data;
                        ot.getTenantOptionExtension().then(function(t) { n.extension = t.data })
                    })
                },
                dr = function(n) { return n && n.length > 0 && _.any(n, function(n) { return n.isShow && ui(n) > 0 }) },
                gr = function() { l.goToOfficeCredits() },
                nu = function() { s.loadPermissions().then(function() { s.isAllowed("tenantSettings.account") && (n.isShowPointLink = !0) }) },
                tu = function() { t(function() { var n = a.open({ animation: !0, backdrop: "static", template: "<face-recognition-view><\/face-recognition-view>", controller: "FaceRecognitionCtrl", size: "md", resolve: { host: function() { return {} } } }) }) },
                iu = function() {
                    vt.readIdentityInfo().then(function(n) {
                        var r, t;
                        if (n && n.issuccess) {
                            var u = n.data,
                                f = u.idcardNumber,
                                i = e.find("#search-input-box");
                            i.val(f);
                            i.click()
                        } else r = "提示", t = "身份证读取失败，请检查身份证读取工具是否正常运行。", n && !n.issuccess && n.msg && (t = n.msg), ht.warn(r, t)
                    }, function() { ht.warn("提示", "身份证读取失败，请检查身份证读取工具是否正常运行。") })
                },
                ru = function() { ut.getIsLcCrmEnabled().then(function(t) { n.isLcCrmEnabled = t }) },
                uu = function() { t(function() { var n = a.open({ animation: !0, backdrop: "static", template: "<memo-edit-view><\/memo-edit-view>", controller: "MemoEditCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { type: "add" } } } }) }) },
                fu = function() {
                    t(function() { var n = a.open({ animation: !0, backdrop: "static", template: "<memo-center-view><\/memo-center-view>", controller: "MemoCenterCtrl", backdropClass: "ares-modal-backdrop" }) });
                    kt("备忘")
                },
                fu = function() {
                    var n = ct.open({ template: "<memo-center-view><\/memo-center-view>", controller: "MemoCenterCtrl", title: "备忘中心", titleIconClass: "iconfont icon-beiwanglu", needActive: !0 });
                    kt("备忘")
                },
                kt = function(n) { Ares.sensors.track("AppTopBarEvent", { EventType: n }) },
                eu = function() {
                    Ares.sensors.track("ClinicCenter", { OperationType: "诊所概览入口" });
                    l.goToEnterpriseCenter()
                },
                ou = function() {
                    n.isShowAppt = !1;
                    var t = e.find("#J_topbar-draggable-box"),
                        i = setInterval(function() {
                            if (t.draggable) {
                                clearInterval(i);
                                t.draggable({ handle: ".draggable-logo", start: function() { Ares.sensors.track("webclick", { OperationType: "拖动网络预约列表", EventType: "网络预约操作" }) } });
                                return
                            }
                        }, 200)
                };
            n.draggableToggle = function(t) {
                n.isShowAppt = t === "on";
                t === "on" ? (Ares.sensors.track("NewAppointmentApply", { OperationType: "网络预约任务列表点击", OperationMode: "展开提醒" }), Ares.sensors.track("webclick", { OperationType: "展开网络预约列表", EventType: "网络预约操作" })) : (Ares.sensors.track("NewAppointmentApply", { OperationType: "网络预约任务列表点击", OperationMode: "收起提醒" }), Ares.sensors.track("webclick", { OperationType: "折叠网络预约列表", EventType: "网络预约操作" }))
            };
            var su = function() {
                    var t = w.expiredDate,
                        i, r;
                    t && (i = moment(t).diff(moment().startOf("d"), "d"), i < 31 && i >= 0 ? (n.showExpiredHint = !0, n.expiredDate = moment(t).format("YYYY-MM-DD")) : i < 0 && (r = moment(t).add(1, "M"), moment().isBefore(r) && cu()))
                },
                oi = function() { n.showExpiredHint = !1 },
                si = function() { n.showUpgradeHint = !1 },
                hu = function() {
                    n.showUpgradeHint = !1;
                    localStorage.setItem("topbar_hideUpgradeHint", "1")
                },
                cu = function() { a.open({ title: "续费", template: "<saas-expired-modal-view><\/saas-expired-modal-view>", windowClass: "saas-expired-modal-window", controller: "SaasExpiredModalCtrl", backdropClass: "saas-expired-modal-backdrop", backdrop: "static" }) },
                lu = function(n) {
                    oi();
                    si();
                    ct.open({ template: '<bms-product-modal-view application-code="\'saas\'" action="1" channel="\'企业中心\'"><\/bms-product-modal-view>', title: n, needActive: !0, customWidth: "1180px" })
                },
                yu = function() { l.goToEnterpriseApplications() },
                au = function() { pt.getCustomerSuccessConsutant().then(function(t) { n.successConsutant = t }) };
            (function() {
                n.isShowStrongMessage = !1;
                n.isStrongMessageDisabled = !1;
                n.isShowMoreMessage = !1;
                n.enabledApptChannel = "";
                n.readIdentityInfo = iu;
                n.popoverPlacement = n.popoverPlacement || "bottom";
                n.pointBoardUrl = "pointBoard.html";
                n.isPointBoardOpened = !1;
                n.bizMessageCodes = [];
                n.apptApplysRemind = {};
                n.checkoutRemind = [];
                n.applyRemind = [];
                n.linkHelpPage = li;
                n.refreshView = ci;
                n.enableScrm = !1;
                n.hideThis = vi;
                n.goToNavigate = yi;
                n.removeMessage = nr;
                n.loginSCRM = ir;
                n.readMessage = rr;
                n.getUnReadCount = ui;
                n.openPointBoard = ei;
                n.closePointBoard = bt;
                n.onMouseLeave = er;
                n.createPatient = or;
                n.isAdminOffice = w.isAdminOffice;
                n.isGroup = w.isGroup;
                n.readCard = wr;
                n.onWebchatClick = br;
                n.isShowMessage = dr;
                n.goToCredits = gr;
                n.recognitionFaceInfo = tu;
                n.editMemoClick = uu;
                n.memoCenterClick = fu;
                n.goToEnterpriseCenter = eu;
                n.goToApptApply = pi;
                n.hideExpiredHint = oi;
                n.hideUpgradeHint = si;
                n.hideUpgradeHintForever = hu;
                n.openBmsSaasModal = lu;
                n.readYibaoCard = sr;
                n.onSelectYibaoChannel = pr;
                ar();
                ru();
                vr();
                at.setIsReadIdentityCardEnabled(n);
                lr();
                kr();
                nu();
                yr();
                f.isInitialized ? t(ni, 200) : u.subscribe(n, "appInitialized", tr);
                n.$on("$destroy", function() { rt.dispose() });
                n.isAdminOffice || t(cr, 5e3);
                t(function() { e.find('[data-toggle="tooltip"]').tooltip() }, 5e3);
                ou();
                su();
                au()
            })()
        }
    }
}]);
frameworkModule.directive("aresNewHomeView", ["$stateParams", "loginContext", "$rootScope", "$document", "$state", "hebePortal", "$timeout", "eventAggregator", function(n, t, i, r, u, f, e, o) {
    "use strict";
    return {
        restrict: "E",
        replace: !1,
        templateUrl: "/app/framework/views/ares-new-home-view.html",
        scope: { targetRoute: "@", useDeputy: "=" },
        link: function(s, h) {
            var a, v, k = "_START_BUSY_REQUEST_",
                d = "_END_BUSY_REQUEST_",
                c = r.find("body").eq(0),
                w = s.useDeputy ? "hebe-deputy-container" : "hebe-container",
                l = "#" + w,
                b = (new Date).getTime(),
                g = function() {
                    var t, n;
                    h.data("timestamp", b);
                    t = localStorage.getItem("isHebeDevMode") === "1";
                    t ? (a = "http://localhost:9636", v = "") : (a = window.location.origin, v = "/SublimeText3Project/yayi/json/index" + "/app-new");
                    n = c.find(l);
                    n.length === 0 ? (i.$broadcast(k), Ares.Loader.loadJs(a + "/SublimeText3Project/yayi/js/plugin.js?v=" + (new Date).getTime(), function() { nt() })) : (y(n), tt(n))
                },
                nt = function() {
                    var f;
                    try {
                        var u = JSON.parse(localStorage.getItem("LogOnResult")),
                            o = { account: u.User.Account, id: u.User.Id, tenantId: u.User.TenantId, tenantName: u.TenantName, isRoot: u.User.IsRoot === "True", provider: { department: u.User.Provider.Department, id: u.User.Provider.Id, job: u.User.Provider.Job, name: u.User.Provider.Name, mobile: u.User.Provider.Mobile }, roleType: u.User.RoleType, loginOfficeId: u.LoginOfficeId, financeDay: window.financeDay },
                            e = angular.element('<div id="' + w + '"><\/div>');
                        // console.log(u);
                        c.append(e);
                        y(e);
                        f = s.targetRoute || s.route;
                        f || (f = n.route);
                        new HebeFrame({
                            hebeOrigin: a,
                            hebePath: v,
                            route: f,
                            apiHost: t.apiHost,
                            accessToken: "bearer " + t.apiToken,
                            other: Base64.encode(JSON.stringify(o)),
                            containerId: w,
                            moduleOption: window.aresModuleOption,
                            onReadyCallback: function() {
                                i.$broadcast(d);
                                r.find(l).data("timestamp", b)
                            }
                        })
                    } catch (h) {
                        console.log(h);
                        console.error("[AresNewHome] token parse error")
                    }
                },
                y = function(n) {
                    n.data("timestamp", b);
                    e(function() {
                        var i, y, u, f, e, o, l;
                        r.find("ares-new-home-view").each(function(n, t) { n === 0 ? i = t : h.data("timestamp") === angular.element(t).data("timestamp") && (i = t) });
                        var t = i.getBoundingClientRect(),
                            p = window.Ares3 ? t.top === 58 && t.left === 88 : t.top === 55 && t.left === 106,
                            a = angular.element(i).closest(".ares-modal-shelf-modal").length > 0,
                            v = angular.element(i).closest(".modal-content").length > 0,
                            s;
                        v && (y = angular.element(i).closest(".modal").css("zIndex"), s = parseInt(y) + 1);
                        l = 0;
                        c[0].scrollHeight !== c[0].clientHeight && (l = 10);
                        p ? (u = 58, f = window.Ares3 ? 88 : 96, e = "calc(100vh - 58px)", o = "calc(100vw - 96px)") : a ? (u = t.top, f = t.left + l, e = t.height, o = t.width) : v ? (u = t.top, f = t.left, e = t.height, o = t.width) : (u = t.top - 8, f = t.left - 8, e = t.height + 16, o = t.width + 16);
                        n.css({ top: u, left: f, height: e, width: o, position: "fixed", zIndex: s ? s : a ? 1040 : 1 }).show()
                    }, 500, !1)
                },
                tt = function(t) {
                    var r = !t.is(":visible"),
                        i = s.targetRoute || n.route;
                    (i === "dentalLab.orderTrack" || i === "modalEntry") && (r = !0);
                    f.post("hebe.router.navigate", { target: i, force: r }, null, !!s.useDeputy)
                },
                p = function() {
                    var n = c.find(l);
                    n.length > 0 && n.is(":visible") && y(n)
                };
            (function() {
                g();
                o.subscribe(s, o.events.sidebarSubMenuToggle, function() { p() });
                o.subscribe(s, o.events.PatientCenterSidePanelToggled, function() { p() });
                o.subscribe(s, o.events.ModalShelfTabChange, function() {
                    var n = c.find(l);
                    y(n)
                });
                h.on("$destroy", function() { u.current.name !== "new" && (r.find(l).each(function(n, t) { angular.element(t).data("timestamp") === h.data("timestamp") && (angular.element(t).hide(), f.post("hebe.router.navigate", { target: "empty" }, null, !!s.useDeputy)) }), window.removeEventListener("resize", p)) });
                window.addEventListener("resize", p)
            })()
        }
    }
}]);
frameworkModule.directive("comingSoonView", ["$log", function() { "use strict"; return { restrict: "E", templateUrl: "/app/framework/views/coming-soon-view.html", replace: !0, link: function() {} } }]);
frameworkModule.directive("emrAllHomeView", ["$log", "appNav", "$state", "$stateParams", "permissionProvider", function(n, t, i, r, u) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/emr-all-home-view.html",
        link: function(n) {
            var f = function(i) { n.selectMenu != i && (n.selectMenu = i, t.switchState(i, { patientId: r.patientId })) },
                e = function() { n.selectMenu = i.includes("patientgeneralMedicalRecords.patientEmr.list") ? "patientgeneralMedicalRecords.patientEmr.list" : i.includes("patientgeneralMedicalRecords.patientGeneralExam.hint") ? "patientgeneralMedicalRecords.patientGeneralExam.hint" : i.includes("patientgeneralMedicalRecords.patientPerioExam.history") ? "patientgeneralMedicalRecords.patientPerioExam.history" : i.includes("patientgeneralMedicalRecords.patientTxplan.list") ? "patientgeneralMedicalRecords.patientTxplan.list" : u.isAllowed("patientMedicalRecord.list") ? "patientgeneralMedicalRecords.patientEmr.list" : u.isAllowed("generalExam.history") ? "patientgeneralMedicalRecords.patientGeneralExam.hint" : u.isAllowed("perioExam.history") ? "patientgeneralMedicalRecords.patientPerioExam.history" : "patientgeneralMedicalRecords.patientTxplan.list" };
            (function() {
                n.onSelected = f;
                e()
            })()
        }
    }
}]);
frameworkModule.directive("messageDetailView", ["$log", "$timeout", "$interpolate", function(n, t) {
    "use strict";
    return {
        restrict: "E",
        replace: !0,
        templateUrl: "/app/framework/views/message-detail-view.html",
        link: function(n, i) {
            (function() {})();
            t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5)
        }
    }
}]);
frameworkModule.directive("messageView", ["$log", "$timeout", "$document", "$state", "eventAggregator", "aresNotification", "loginContext", "speechCallSvc", "officeOptionSvc", "$q", "hebePortal", function(n, t, i, r, u, f, e, o, s, h, c) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/message-view.html",
        replace: !0,
        scope: {},
        controller: "MessageCtrl",
        link: function(n, r) {
            var l = [],
                a = null,
                v = null,
                g = function(t, i) {
                    var r = $(t.target).hasClass("message-close-btn");
                    r || n.goToNavigate(i)
                },
                nt = function(t, i) {
                    var r = $(t.target).hasClass("message-close-btn");
                    r || n.readMessage(i)
                },
                tt = function() {
                    n.initMessageConfig().then(function() {
                        var t = r.find("#messageCenterContent");
                        if (t.is(":visible")) t.hide();
                        else {
                            t.show();
                            n.loadMessage(!0);
                            b.onMousedown(it)
                        }
                    })
                },
                b = Ares.globalEventUtil(i),
                it = function(n) {
                    var t = $(n.target).hasClass("bell"),
                        i = r.find("#messageCenterContent"),
                        u = $(n.target).parents(".message-content").length;
                    u != 0 || t || (i.hide(), b.offMousedown())
                },
                rt = function() {
                    u.subscribe(n, u.events.AppointmentCreated, y);
                    u.subscribe(n, u.events.AppointmentUpdated, y);
                    (e.dashboardType == "FrontDesk" || e.dashboardType == "Doctor") && (u.subscribe(n, u.events.ChargeOrderChanged, p), u.subscribe(n, u.events.ChargeOrderCreated, p), u.subscribe(n, u.events.SpeechCallReceived, k));
                    u.subscribe(n, u.events.MessageCenterChanged, d)
                },
                y = function(n, t) { t._apptAction && (t._apptAction.indexOf("Undo") >= 0 || t._apptAction.indexOf("CheckOut") >= 0) || (t._apptAction == "CheckIn" || (n.name = "AppointmentCreated" && t.isCheckedIn && t._apptAction != "Complete" && t._apptAction != "Left" && t._apptAction != "Seat") ? (e.dashboardType == "Consultant" && t.consultantId == e.providerId || e.dashboardType == "Doctor" && t.doctorId == e.providerId || e.dashboardType == "Assistant" && t.assistantId == e.providerId) && s.isOfficeOptionTrue(s.optionKeys.CheckInNotifyDoctor).then(function() { f.playSound("checkIn") }) : e.dashboardType == "FrontDesk" && t._apptAction == "Complete" && s.isOfficeOptionTrue(s.optionKeys.CompleteNotifyFront).then(function() { f.playSound() })) },
                p = function(n, t) { t.moduleLevelOne == "患者收费" && t.moduleLevelTwo == "收费" ? e.dashboardType == "Doctor" && s.isOfficeOptionTrue(s.optionKeys.ChargeCompleteNotifyDoctor).then(function() { f.playSound() }) : e.dashboardType == "FrontDesk" && s.isOfficeOptionTrue(s.optionKeys.ChargeNotifyFront).then(function() { f.playSound() }) },
                k = function(t, i) {
                    e.dashboardType == "FrontDesk" && s.isOfficeOptionTrue(s.optionKeys.IsOpenSpeechCall).then(function() {
                        s.getOfficeOption(s.optionKeys.SpeechCallTimes).then(function(t) {
                            ut().then(function(r) {
                                var s = r.access_token,
                                    u = "http://tsn.baidu.com/text2audio?",
                                    f, o;
                                u += "tex=" + i.payload.url;
                                u += "&lan=zh&spd=4";
                                u += "&cuid=" + e.tenantId + "_" + e.officeId;
                                u += "&ctp=1&tok=" + s;
                                n.speechCallTimes = t ? t : 1;
                                f = { messageId: n.messageId++, soundUrl: u, times: n.speechCallTimes, receivedTime: new Date };
                                l.push(f);
                                l.length == 1 ? w(f) : (st(), l.length > 0 && (o = l[0], a != o && w(o)))
                            }, function() { f.error("叫号失败") })
                        })
                    })
                },
                d = function(t, i) {
                    var r = [],
                        u;
                    if (i && i.payload && i.payload.noticeUserIds && (u = _.find(i.payload.noticeUserIds, function(n) { return n == e.userId }), u)) switch (i.payload.messageType) {
                        case "审批提醒":
                            r.push(n.keys.workflowReminderCode)
                    }
                    r.length > 0 && n.loadPermissionMessage(r, !1, !0, !0)
                },
                ut = function() {
                    var n = h.defer();
                    return v ? n.resolve(v) : o.getSpeechCallToken().success(function(t) {
                        var i = JSON.parse(t);
                        v = i;
                        n.resolve(v)
                    }).error(function() { n.reject() }), n.promise
                },
                ft = function() {
                    u.unsubscribe(n, u.events.AppointmentCreated, y);
                    u.unsubscribe(n, u.events.AppointmentUpdated, y);
                    (e.dashboardType == "FrontDesk" || e.dashboardType == "Doctor") && (u.unsubscribe(n, u.events.ChargeOrderChanged, p), u.unsubscribe(n, u.events.ChargeOrderCreated, p), u.unsubscribe(n, u.events.SpeechCallReceived, k));
                    u.unsubscribe(n, u.events.MessageCenterChanged, d)
                },
                et = function() {
                    if (a = null, l.splice(0, 1), l.length > 0) {
                        var n = l[0];
                        w(n)
                    }
                },
                ot = function() {
                    var n, t, i;
                    a = null;
                    n = moment(new Date);
                    t = moment(n).diff(l[0].startTime, "seconds");
                    t > 5 && l.splice(0, 1);
                    l.length > 0 && (i = l[0], w(i))
                },
                w = function(n) { n != a && (a = n, n.startTime = n.startTime || new Date, f.playSoundEx(n.soundUrl, n.times, et, ot)) },
                st = function() { for (var t, i, r = moment(new Date), n = l.length - 1; n >= 0; n--) t = l[n], i = moment(r).diff(t.receivedTime, "seconds"), i > 300 && l.splice(n, 1) };
            (function() {
                if (n.messageId = 1, n.speechCallQueue = l, n.goToNavigateEx = g, n.readMessageEx = nt, n.toggle = tt, n.ares3 = window.Ares3, window.Ares3 ? r.find('[data-toggle="tooltip"]').removeAttr("title") : t(function() { r.find('[data-toggle="tooltip"]').tooltip() }, 200), rt(), n.$on("$destroy", function() {
                        ft();
                        b.dispose()
                    }), n.ares3) {
                    r.on("click", ".bell-wrapper", function() {
                        var n = $("#messageCenterContent");
                        n.is(":visible") && c.post("hebe.event.topbarMenuShown", null)
                    });
                    c.register("ares.event.globalClick", function() {
                        $("#messageCenterContent").hide();
                        c.post("hebe.event.topbarMenuHidden", null)
                    })
                }
            })()
        }
    }
}]);
frameworkModule.directive("officePointDialogView", ["$log", "toothUtil", "appNav", function(n, t, i) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/office-point-dialog-view.html",
        scope: !0,
        link: function(n) {
            var t = function() {
                n.isPointBoardOpened = !1;
                i.goToOfficeInfo();
                n.closePointBoard()
            };
            (function() { n.goToOffice = t })()
        }
    }
}]);
frameworkModule.directive("officeSwitchView", ["$log", "$q", "$timeout", "officeSvc", "officeSelectorUtil", "loginContext", "aresNotification", function(n, t, i, r, u, f, e) {
    return {
        restrict: "E",
        replace: !0,
        templateUrl: "/app/framework/views/office-switch-view.html",
        link: function(n, o) {
            var s = function() {
                    return _.debounce(function() {
                        i(function() {
                            n.officeTreeData = u.getSearchedOffices(n.officeSearchContent, n.srcOfficeTreeData);
                            i(function() { n.treeInstance.initSelectedData() })
                        })
                    }, 300)
                },
                h = function() {
                    var i = t.defer(),
                        e = f.offices || [];
                    return r.getWorkingGroup(e).success(function(t) {
                        var s = u.setExtraFields(t),
                            r, o;
                        s = u.setId(s);
                        r = u.flattenToMap(s);
                        r = _.values(r);
                        r.forEach(function(n) {
                            f.isTenantAdmin || (n.disabled = _.contains(e, n.id) ? !1 : !0);
                            n.textLabel = "(" + n.abbr + ")" + n.name
                        });
                        n.srcOfficeTreeData = u.unflatten(r);
                        n.officeTreeData = angular.copy(n.srcOfficeTreeData);
                        n.currentOffice = u.getOfficeByOfficeId(n.srcOfficeTreeData, f.officeId);
                        o = r.length * 34;
                        o = o > 400 ? 400 : o;
                        n.selecterHeigthStr = o + "px";
                        i.resolve()
                    }), i.promise
                },
                c = function() {
                    if (!n.selectedOffice) { e.error("请选择要切换的诊所！"); return }
                    if (n.selectedOffice.id == n.currentOffice.id) { e.error("本诊所无法进行切换！"); return }
                    var t = n.selectedOffice.id;
                    t && n.switchOffice(t)
                };
            (function() {
                n.checkbox = !1;
                n.checkboxLinkage = !1;
                n.treeInstance = null;
                n.onSearchOffice = s();
                n.ok = c;
                h().then(function() { i(function() { Ares.centerModal(o.closest(".modal-dialog")) }, 100) })
            })()
        }
    }
}]);
frameworkModule.directive("patientHostView", ["$log", "$timeout", "eventAggregator", "appNavItemProvider", "aresNotification", "moduleUtil", "patientTabManager", "permissionProvider", "loginContext", "$rootScope", function(n, t, i, r, u, f, e, o, s, h) {
    "use strict";
    return {
        restrict: "E",
        replace: !1,
        templateUrl: "/app/framework/views/patient-host-view.html",
        controller: "PatientHostCtrl",
        link: function(n, c) {
            var v = window.Ares3 ? 200 : 96,
                p = 195,
                y = 4,
                l, w = function() {
                    i.subscribe(n, i.events.AppSideBarToggled, b);
                    i.subscribe(n, i.events.sidebarSubMenuToggle, function(n, t) {
                        v = t && t.subMenuVisible ? 200 : 80;
                        a()
                    })
                },
                b = function() {
                    var n = c.find(".k-splitter");
                    n && kendo.resize(n)
                },
                a = function() {
                    var t = $(window).width();
                    n.patientContentWidth = n.isShowBanner ? t - v - p - y : t - v - y;
                    window.Ares3 && (l || (l = c.find("#patientContainer").data("kendoSplitter")), l.size(".k-pane:first", 195))
                },
                k = function() {
                    if (!e.activeTab) { u.success("列表不可收起。"); return } l || (l = c.find("#patientContainer").data("kendoSplitter"));
                    l.toggle(".k-pane:first");
                    n.isShowBanner = !n.isShowBanner;
                    a();
                    i.publish(i.events.PatientCenterSidePanelToggled, {})
                },
                d = function() { $(window).resize(function() { t(function() { a() }) }) };
            (function() {
                n.isAdminOffice = s.isAdminOffice;
                n.hasPermission = o.isAllowed("patientCenter.allPatients");
                n.hasMyPatientsPermission = s.providerJob == "网电营销" && h.isNewWxEnabled;
                n.isPatientHostEverVisible = !1;
                n.isShowBanner = !0;
                n.onToggleBanner = k;
                n.patientHostState = r.patientHost;
                n.patientTabManager = e;
                a();
                w();
                d();
                f.load("ehr")
            })()
        }
    }
}]);
frameworkModule.directive("patientInfoView", ["$log", "appNav", function(n, t) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/patient-info-view.html",
        replace: !0,
        controller: "PatientInfoCtrl",
        scope: { patientId: "@", isVisible: "@" },
        link: function(n) {
            var i = function() { t.goToPatient(n.patient.id, "record") };
            (function() {
                n.goToPatient = i;
                n.$watchGroup(["isVisible", "patientId"], function() {
                    var t = n.isVisible == "true";
                    t && n.patientId && n.getPatientInfo(n.patientId)
                });
                n.leftheight = $(window).height() - $("topbar").height() - 55 + "px"
            })()
        }
    }
}]);
frameworkModule.directive("patientMainInfoView", ["$log", "$modal", "$q", "$filter", "aresDialog", "$rootScope", "patientUtil", "shortMessageUtil", "appNav", "patientSvc", "conversationSvc", "phoneSvc", "aresNotification", "loginContext", "apptUtil", "eventAggregator", "$injector", "$state", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/patient-main-info-view.html",
        replace: !0,
        scope: !0,
        controller: "PatientMainInfoCtrl",
        link: function(c, w) {
            var d = function() {
                    v.isAdminOffice ? e.createCrossOfficeFollowUpAppt(c.currentPatientId).then(function(n) { n && a.success("预约成功") }) : v.isGroup ? e.createGroupFollowUpAppt(c.currentPatientId).then(function(n) { n && a.success("预约成功") }) : y.isAllowApptToConsultant().then(function(n) { n ? h.getPatientConsultantId(c.currentPatientId).then(function(n) { e.createFollowUpApptByPatientId(c.currentPatientId, null, null, n.data).then(function(n) { n && a.success("预约成功") }) }) : e.createFollowUpApptByPatientId(c.currentPatientId).then(function(n) { n && a.success("预约成功") }) });
                    Ares.sensors.track("PatientMainInfo", { OperationType: "创建预约" });
                    window.Ares3 && Ares.sensors.track("NewAppointmentCreate", { OperationType: "新建预约", OperationMode: "患者中心-患者详情" })
                },
                g = function() {
                    v.isGroup ? e.createGroupFollowUpAppt(c.currentPatientId).then(function(n) { n && a.success("预约成功") }) : e.createCrossOfficeFollowUpAppt(c.currentPatientId).then(function(n) { n && a.success("预约成功") });
                    Ares.sensors.track("PatientMainInfo", { OperationType: "创建跨诊所预约" })
                },
                nt = function() {
                    o.sendMessage(c.currentPatientId, -1);
                    Ares.sensors.track("PatientMainInfo", { OperationType: "发送信息" })
                },
                tt = function() {
                    var t = c.patientTabManager.activeTab.patient,
                        n;
                    f.isNewWxEnabled && (n = t.marketCenterAccount, f.$broadcast("start-chat", n))
                },
                it = function() { f.isNewWxEnabled ? ut() : u.warn("提示", "当前诊所未开通SCRM！") },
                rt = function() {
                    s.goToPatientVideo();
                    Ares.sensors.track("$webClick", { $element_content: "患者中心- 医患沟通视频" })
                },
                ut = function() {
                    Ares.sensors.track("PatientMainInfo", { OperationType: "微信公众号" });
                    h.generatePatientQrCode(c.currentPatientId).then(function(i) {
                        var r, u;
                        i ? (r = { interval: 3e3, delay: 100, maxCount: 20, bindWeiXin: !0, queryFunc: ft }, h.sendScrmQrCode(i).success(function() { n.log("scrm2.0发送二维码到智能话机成功") }).error(function(t) { n.log(t) }), u = t.open({ animation: !0, backdrop: "static", template: "<qrcode-dialog><\/qrcode-dialog>", controller: "QrcodeDialogCtrl", size: "sm", resolve: { host: function() { return { qrCode: i, outTradeNo: 1, isMarketCenter: !1, queryOption: r } } } }), u.result.then(function() {
                            h.getPatient(c.currentPatientId).success(function(n) {
                                c.patientTabManager.activeTab.patient.marketCenterAccount = n.marketCenterAccount;
                                n && n.marketCenterAccount && a.success("微信绑定成功")
                            })
                        })) : a.error("该诊所未授权微信公众号")
                    }).error(function(t) {
                        a.error("获取二维码失败！");
                        n.log(t)
                    })
                },
                ft = function() { var n = i.defer(); return h.getPatient(c.currentPatientId).success(function(t) { t.marketCenterAccount && (f.$broadcast("bind-weixin", t.marketCenterAccount), n.resolve({ result: !0 })) }), n.promise },
                et = function() { w.find("#noteBoard").popover().click(function(n) { n.preventDefault() }) },
                ot = function(n) {
                    n.tags ? angular.forEach(n.tags, function(n) { n.textColor = n.itemValue ? Ares.getForegroundColor(n.itemValue) : Ares.getForegroundColor("#fff") }) : h.getPatientTags(n.id).success(function(t) {
                        t && t.length > 0 && (angular.forEach(t, function(n) {
                            n.textColor = n.itemValue ? Ares.getForegroundColor(n.itemValue) : Ares.getForegroundColor("#fff");
                            n.title = n.isHidden ? "" : n.itemName
                        }), n.tags = t)
                    })
                },
                st = function(n) { n && n.pictureId ? h.getPictureById(n.pictureId, !0).success(function(t) { n.imgSrc = t != null ? t.filePath : r("patientPhoto")(null, n) }) : n.imgSrc = r("patientPhoto")(null, n) },
                ht = function() { return v.isRegularChain && v.hasMultiOffices },
                ct = function() { l.checkService().then(function(n) { n && n.data && n.data.issuccess && (c.phoneServiceEnabled = !0, w.find("#patientPhoneDropdown").dropdown()) }) },
                lt = function(n) {
                    h.getMobileAndPhoneNumberByPatientId(n).success(function(n) {
                        var t = !1,
                            i = _.filter(n, function(n) { return n.mobile !== "" });
                        i.length > 0 && (t = !0, c.currentPatientPhones = _.sortBy(i, "displayOrder"));
                        c.showPatientPhoneDropdown = t
                    })
                },
                at = function(n) { n.mData && n.mData.mobileEncrypted ? h.decodeData(n.mData.mobileEncrypted).success(function(n) { b(n) }) : b(n.mobile) },
                b = function(n) { l.makeCall({ phonenumber: n }).then(function(n) { n && n.data && n.data.issuccess ? a.success("电话呼出成功！") : a.error("电话呼出失败！" + n.data.msg || "") }).catch(function() { a.error("电话呼出失败！") }) },
                vt = function() { p.subscribe(c, p.events.PatientSourceTypeChanged, k) },
                yt = function() { p.unsubscribe(c, p.events.PatientSourceTypeChanged, k) },
                k = function(n, t, i) { i == "PatientCheckInCtrl" && e.initPatient(c.patientTabManager.activeTab.patient.id).then(function(n) { n && n.sourceType && (c.patientTabManager.activeTab.patient.sourceType = n.sourceType, c.patientTabManager.activeTab.patient.sourceTypeLevel1 = n.sourceTypeLevel1) }) };
            (function() {
                c.createAppt = d;
                c.createCrossOfficeAppt = g;
                c.loginContext = v;
                c.isAdminOffice = v.isAdminOffice;
                c.getPatientQrCode = it;
                c.getPatientVideo = rt;
                c.allowCrossOfficeAppt = ht;
                c.sendMessage = nt;
                c.patientConversation = tt;
                c.phoneServiceEnabled = !1;
                c.showPatientPhoneDropdown = !1;
                c.isProfessional = v.isProfessional;
                c.makePhoneCall = at;
                et();
                ct();
                vt();
                c.$on("$destroy", function() { yt() });
                c.$watch("patientTabManager.activeTab", function() {
                    if (c.patientTabManager.activeTab && c.patientTabManager.activeTab.patient) {
                        var n = c.patientTabManager.activeTab.patient;
                        p.publish(p.events.MainInfoPatientChanged, n, "PatientMainInfo");
                        n ? (c.currentPatientId = n.id, ot(n), lt(n.id)) : c.currentPatientId = null
                    }
                });
                c.$watchGroup(["patientTabManager.activeTab.patient.pictureId", "patientTabManager.activeTab.patient.sex", "patientTabManager.activeTab.patient.birth"], function() {
                    if (c.patientTabManager.activeTab && c.patientTabManager.activeTab.patient) {
                        var n = c.patientTabManager.activeTab.patient;
                        st(n)
                    }
                })
            })()
        }
    }
}]);
frameworkModule.directive("patientMenuBar", ["$log", "loginContext", "eventAggregator", function(n, t, i) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/patient-menu-bar.html",
        replace: !0,
        scope: !0,
        controller: "PatientMenuBarController",
        link: function(n) {
            var u = 130,
                f = 80,
                r = function() {
                    var o = parseInt((n.patientContentWidth - u) / f),
                        t, i, r, e;
                    if (n.patientTabManager && n.patientTabManager.activeTab) {
                        console.log(n.patientTabManager.activeTab.menus)
                        if (t = _.filter(n.patientTabManager.activeTab.menus, function(n) { return n.isVisable }), t && (t = _.sortBy(t, "index")), angular.forEach(t, function(n, t) { n.isShow = t < o ? !0 : !1 }), n.patientTabManager.activeTab.showUserMenus = _.filter(t, function(n) { return n.isShow }), n.patientTabManager.activeTab.hideUserMenus = _.filter(t, function(n) { return !n.isShow }), i = _.find(n.patientTabManager.activeTab.hideUserMenus, function(n) { return n.active }), i && (r = _.findIndex(n.patientTabManager.activeTab.hideUserMenus, function(n) { return n.id == i.id }), r > -1)) n.onMenuSelected(i);
                        e = n.patientTabManager.activeTab.showUserMenus.length;
                        n.lastLiWidth = n.patientContentWidth - e * f - u;
                        n.showMoreBtn = n.patientTabManager.activeTab.hideUserMenus && n.patientTabManager.activeTab.hideUserMenus.length > 0
                    }
                },
                e = function(t, i) {
                    t.isHover = !0;
                    n.patientTabManager.activeTab.hideUserMenus[i].isHideBorder = !0;
                    i > 0 && (n.patientTabManager.activeTab.hideUserMenus[i - 1].isHideBorder = !0)
                },
                o = function(t) {
                    t.isHover = !1;
                    angular.forEach(n.patientTabManager.activeTab.hideUserMenus, function(n) { n.isHideBorder = !1 })
                };
            (function() {
                n.isShowSetting = !t.isAdminOffice;
                n.isShowMoreMenu = !1;
                n.onHideMenuMousemove = e;
                n.onHideMenuMouseleave = o;
                n.init = r;
                n.$watch("patientTabManager.activeTab", function() { n.patientTabManager.activeTab && r() });
                n.$watch("patientContentWidth", function() { n.patientContentWidth && r() });
                i.subscribe(n, i.events.PatientTabManagerInitialized, function() { r() })
            })()
        }
    }
}]);
frameworkModule.directive("patientMenuConfigView", ["$log", "$timeout", function(n, t) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/patient-menu-config-view.html",
        replace: !0,
        link: function(n, i) {
            (function() {})();
            t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5)
        }
    }
}]);
frameworkModule.directive("patientNavBar", ["$log", "$modal", "$state", "$timeout", "appNav", "permissionProvider", "loginContext", "patientUtil", function(n, t, i, r, u, f, e, o) {
    "use strict";
    return {
        restrict: "E",
        templateUrl: "/app/framework/views/patient-nav-bar.html",
        replace: !0,
        scope: !0,
        controller: "PatientNavBarController",
        link: function(n) {
            var t = function(n) { n.patient.isItemHover = !1 },
                s = function(n) { n.patient.isItemHover = !0 },
                h = function() { $.fn.mCustomScrollbar && ($(".patient-nav-container").mCustomScrollbar({ scrollButtons: { enable: !1 }, autoHideScrollbar: !0, scrollInertia: 150, advanced: { updateOnContentResize: !0 } }), r(function() { u.scrollToPatient(i.params.patientId) }, 500)) },
                c = function() {
                    var t = o.getPatientSearchState();
                    n.selectTab(t)
                };
            (function() {
                n.isOfficePatient = !e.isGroup;
                n.hasPermission = f.isAllowed("patientCenter.allPatients");
                n.patientQueryBtnClass = "patient-query-btn";
                n.revisitBtnClass = "revisit-btn";
                n.fontColor = "";
                n.onItemMouseHover = s;
                n.onItemMouseLeave = t;
                n.selectPatientQueryTab = c;
                h()
            })()
        }
    }
}]);